---
title: "SQL-004: Retrieve agency contracts"
summary: Retrieve agency-contract rows with optional agency scoping.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Agency
reference_type: package
---

# SQL-004: Retrieve agency contracts

This statement drives `clsAgencyContractCollection` retrieval. It returns all contract rows when no agency sequence number is supplied and narrows the result set to one agency when the criteria includes `:AgencySeqNum`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-004 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | `[unqualified]` |
| **Command type** | Text |
| **Business object** | `clsAgencyContractCollection` |
| **Criteria property** | `RetrieveSQL` |
| **Lifecycle method** | `BeforeRetrieve` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:AgencySeqNum` | Input (conditional) | Decimal (`NUMBER`) | N/A | Agency sequence number, bound only when the collection is scoped to one agency. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [AGENCY_CONTRACT](../database-tables.md#agency_contract) | SELECT | `AGENCY_CONTRACT_SEQ_NUM`, `AGENCY_CONTRACT_TYPE_CODE`, `AGENCY_SEQ_NUM`, `COMM_GL_TYPE_CODE`, schedule IDs, effective and expiration dates |

## Sample SQL

```sql
Select
  AGENCY_CONTRACT.AGENCY_CONTRACT_SEQ_NUM as AgencyContractSeqNum,
  AGENCY_CONTRACT.AGENCY_CONTRACT_TYPE_CODE as AgencyContractTypeCode,
  AGENCY_CONTRACT.AGENCY_PAYMENT_FREQ_CODE as AgencyPaymentFreqCode,
  AGENCY_CONTRACT.AGENCY_SEQ_NUM as AgencySeqNum,
  AGENCY_CONTRACT.COMM_GL_TYPE_CODE as CommGLTypeCode,
  AGENCY_CONTRACT.CREATE_DATE as CreateDate,
  AGENCY_CONTRACT.CREATE_USER as CreateUser,
  AGENCY_CONTRACT.DEFAULT_COMM_SCHED_ID as DefaultCommSchedID,
  AGENCY_CONTRACT.EFF_DATE as EffDate,
  AGENCY_CONTRACT.EXP_DATE as ExpDate,
  AGENCY_CONTRACT.LEGACY_COMM_SCHED_ID as LegacyCommSchedID,
  AGENCY_CONTRACT.LEGACY_RNW_COMM_SCHED_ID as LegacyRnwCommSchedID,
  AGENCY_CONTRACT.PMS_AGENCY_NUM as PmsAgencyNum,
  AGENCY_CONTRACT.RENEWAL_COMM_SCHED_ID as RenewalCommSchedID
From AGENCY_CONTRACT
Where
  AGENCY_CONTRACT.AGENCY_SEQ_NUM = :AgencySeqNum
```

## Operations and processes
- [Bulk-load contracts for a set of agencies](../operations/bulk-load-contracts-for-a-set-of-agencies.md)
- [Determine an agency's contract type on a date](../operations/determine-an-agencys-contract-type-on-a-date.md)
- [Retrieve agency contracts](../operations/retrieve-agency-contracts.md)
- [Determine agency eligibility for an office](../operations/determine-agency-eligibility-for-an-office.md)
- [Determine producer-commission eligibility](../operations/determine-producer-commission-eligibility.md)

## Business rules
- [BR-006: Bulk loaders discard orphan child rows](../business-rules.md#br-006-bulk-loaders-discard-orphan-child-rows)
- [BR-010: Agency-contract collection scope depends on agency sequence number](../business-rules.md#br-010-agency-contract-collection-scope-depends-on-agency-sequence-number)
- [BR-024: The library is retrieve-only](../business-rules.md#br-024-the-library-is-retrieve-only)

## Sources
- `Business\SAIF.Business.Policy.Agency\clsAgencyContractCollection.vb`
