---
title: Insert a policy output document
summary: Persist a policy output-document record through the `pk73343_output_document` Oracle package.
status: draft
owner: Technical Writer
last_reviewed: 2026-07-31
library: SAIF.Business.Policy.Correspondence
reference_type: package
operation_id: OP-007
trigger: Caller invokes `InsertOutputDocument` or `InsertAgencyDeliveredOutputDocument` on `clsOutputDocumentInserter`.
---

# Insert a policy output document

Persist a policy output-document record through the `pk73343_output_document` Oracle package.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-007 |
| **Trigger** | Caller invokes `InsertOutputDocument` or `InsertAgencyDeliveredOutputDocument` on `clsOutputDocumentInserter`. |
| **Inputs** | An `OutputDocumentInsert` DTO containing policy, image, delivery, release, and description fields. |
| **Outputs** | A stored `OUTPUT_DOCUMENT` / `POLICY_OUTPUT_DOCUMENT` pair. |
| **Primary components** | `clsOutputDocumentInserter.InsertOutputDocument`; `clsOutputDocumentInserter.InsertAgencyDeliveredOutputDocument` |
| **Entry point** | `Business\SAIF.Business.Policy.Correspondence\clsOutputDocumentInserter.vb` |

## Steps

1. Build a non-query portal request for `pk73343_output_document.insert_policy_output_document` and bind the DTO values needed by the package ([SQL-004](../sql/SQL-004-saif-business-policy-correspondence.md)).
2. The standard insert path binds the common fields; the agency-delivered path adds `in_agency_delivery_flag = Y` before dispatching ([BR-005](../business-rules.md#br-005-agency-delivered-output-documents-add-an-agency-delivery-flag), [BR-031](../business-rules.md#br-031-the-agency-delivered-overload-passes-the-delivery-flag-through-unchanged)).
3. Inside the package, the core procedure computes the document create date, allowing an explicit release date to override the package default ([BR-024](../business-rules.md#br-024-explicit-release-dates-override-the-computed-document-date)).
   - It inserts the base [OUTPUT_DOCUMENT](../database-tables.md#output_document) row and captures the generated key.
   - It reads [OUTPUT_DOCUMENT_TYPE_CODE](../database-tables.md#output_document_type_code) to derive `RELE`, `HELD`, or `PEND` status ([BR-025](../business-rules.md#br-025-non-agency-viewable-output-documents-release-immediately), [BR-026](../business-rules.md#br-026-held-output-documents-require-both-agency-visibility-and-hold-flag), [BR-027](../business-rules.md#br-027-agency-viewable-non-held-documents-start-pending)).
   - It inserts the [POLICY_OUTPUT_DOCUMENT](../database-tables.md#policy_output_document) row, normalizing zero agency or agent values to `NULL` and setting `RELEASE_DATE` only for released rows ([BR-028](../business-rules.md#br-028-zero-agency-and-agent-numbers-are-normalized-to-null), [BR-029](../business-rules.md#br-029-release-dates-are-set-only-for-released-policy-output-rows)).
   > **Origin**: These database-side sub-steps are implemented in [pk73343_output_document](../procedures/pk73343_output_document.md#operations).
4. The 11-argument wrapper always delegates as a non-agency-delivered document, while the 12-argument wrapper passes the delivery flag through unchanged ([BR-030](../business-rules.md#br-030-the-standard-output-document-overload-defaults-to-non-agency-delivery), [BR-031](../business-rules.md#br-031-the-agency-delivered-overload-passes-the-delivery-flag-through-unchanged)).
5. Any package exception is re-raised through the SAIF standard error handler rather than being swallowed ([BR-032](../business-rules.md#br-032-the-output-document-procedure-raises-a-standard-saif-error-on-exception)).

## Process flow

The following diagram summarizes the control flow for this operation.

```mermaid
flowchart TD
    Start([Insert output document]) --> Bind[Bind DTO fields] --> Proc[Call SQL-004] --> Status[Derive RELE / HELD / PEND] --> Link[Insert policy link row] --> Return([Procedure completes])
```

## Failure and edge-case behavior

- Validation and framework state errors surface through the BOF error collection unless the called dependency throws directly.
- Database-dependent operations rely on the caller-supplied data portal context and Oracle connectivity.
- Imaging reconciliation and stored-procedure wrappers defer cross-system behavior to their external collaborators.

## 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.Policy.Correspondence\clsOutputDocumentInserter.vb``
