---
title: Bulk-load producers for a set of agencies
summary: Populate each agency's producer child collection in one pass.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Agency
reference_type: package
operation_id: OP-003
trigger: A caller bulk-loads producer children after loading agencies.
---

# Bulk-load producers for a set of agencies

This operation avoids per-agency lazy producer retrieval by loading all producer rows once and then distributing them to the matching agencies already present in a collection.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-003 |
| **Trigger** | A caller invokes `clsAgencyCollection.RetrieveProducers()`. |
| **Inputs** | Populated `clsAgencyCollection` |
| **Outputs** | Agency `Producers` collections populated in memory |
| **Primary components** | `clsAgencyCollection.RetrieveProducers`, `clsProducerCollection.GetProducerCollection` |
| **Entry point** | `Business\SAIF.Business.Policy.Agency\clsAgencyCollection.vb` |

## Steps
1. Retrieve the full producer collection by executing [SQL-009](../sql/SQL-009-retrieve-producers.md) against [AGENT](../database-tables.md#agent).
2. Reset each agency's producer child collection to a fresh empty collection before assignment.
3. Iterate the retrieved producer rows and locate the parent agency by `AgencySeqNum` ([BR-025](../business-rules.md#br-025-identity-keys-are-agency-seq-contract-seq-and-agent-number)).
4. Add each producer to the matching agency when the parent exists; otherwise discard the row silently ([BR-006](../business-rules.md#br-006-bulk-loaders-discard-orphan-child-rows)).
5. Return with every in-scope agency carrying an in-memory producer collection populated from the shared query ([BR-007](../business-rules.md#br-007-bulk-loaders-replace-n-plus-1-child-retrieval), [BR-023](../business-rules.md#br-023-producer-agencies-are-detected-when-agency-sequence-number-equals-agent-number)).

## Process flow

The following diagram visualizes the producer bulk-load path.

```mermaid
flowchart TD
  Start([RetrieveProducers]) --> Query[Run SQL-009]
  Query --> Reset[Reset each agency producer collection]
  Reset --> Match{Parent agency found?}
  Match -->|Yes| Add[Add producer to agency]
  Match -->|No| Drop[Discard row]
  Add --> End([Child collections populated])
  Drop --> End
```

## Failure and edge-case behavior
- Producers whose parent agency is not already in the collection are ignored.
- The bulk query still reads all producers when no agency filter is applied.

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

## Sources
- `Business\SAIF.Business.Policy.Agency\clsAgencyCollection.vb`
- `Business\SAIF.Business.Policy.Agency\clsProducerCollection.vb`
