---
title: Zip code routing lookup
summary: Resolves county, office, and audit-office routing metadata for a zip code.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-30
library: SAIF.Business.External.Users
reference_type: package
operation_id: OP-EU-08
trigger: Caller requests `clsZipCode.GetZipCode` for routing or validation.
---

# Zip code routing lookup

This operation reads the premium-audit zip-code routing view backed by `PA_ZIP_CODE`, `COUNTY`, and `OFFICE_CODE`. It returns the routing object used by auditor-assignment validation and other location-based decisions.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-EU-08 |
| **Trigger** | Caller needs routing details for a postal zip code |
| **Inputs** | Zip code |
| **Outputs** | Populated `clsZipCode` object or an empty lookup object |
| **Primary components** | `clsZipCode.GetZipCode` |
| **Entry point** | `Business\SAIF.Business.External.Users\clsZipCode.vb` |

## Steps

1. **Build the retrieve request for the supplied zip code.** `BeforeRetrieve` appends `where zip_code = :ZipCode` to the lookup SQL and binds the five-character zip code parameter ([SQL-037](../sql/SQL-037-saif-business-external-users.md), [PA_ZIP_CODE](../database-tables.md#pa_zip_code)).
2. **Read the routing projection from the joined tables.** The SQL selects the zip row, county, office, and audit-office descriptions, using `NVL(z.audit_office_code, c.office_code)` so county office routing fills in when no audit-office code is stored ([SQL-037](../sql/SQL-037-saif-business-external-users.md), [PA_ZIP_CODE](../database-tables.md#pa_zip_code), [COUNTY](../database-tables.md#county), [OFFICE_CODE](../database-tables.md#office_code)).
3. **Hydrate the lookup object when a row exists.** `Load` copies zip code, state, county, office, audit-office, and policy-region values into the business object.
4. **Return an empty object when no row matches.** `AfterRetrieve` creates a fresh `clsZipCode` instead of throwing when the data reader is empty.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
    Start([Zip lookup request]) --> Query[Query routing tables by zip code]
    Query --> Match{Row found?}
    Match -->|Yes| Fill[Populate routing object]
    Match -->|No| Empty[Create empty lookup object]
    Fill --> Done([Return zip routing result])
    Empty --> Done
```

## Failure and edge-case behavior

- Missing routing data does not raise a persistence error; callers receive an empty object.
- The object prefers the audit-office code when present and falls back to the county office code otherwise.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

## Sources
- `Business\SAIF.Business.External.Users\clsZipCode.vb`
