---
title: "SQL-006: clsXDocument.InsertSQL"
summary: Inserts a single print job document into XDOCUMENT.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Services.Printing.Remote
reference_type: package
---

# SQL-006: clsXDocument.InsertSQL

Inserts a new row into `XDOCUMENT`, recording a print job document linked to a print-control batch. Captures routing metadata (bin type, sort values), document type, email/fax addresses, index content text, print group label, duplex code, and the primary key generated via `GetNextSeqNum("XDOCUMENT_SEQ")`. New instances default `XBinTypeCode = "AUTO"` and `CopiesCount = 1` per [BR-005](../business-rules.md#br-005-default-bin-type-on-document-creation).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-006 |
| **Operation type** | Create (Insert) |
| **Execution method** | Inline |
| **Database** | Oracle |
| **Schema** | `[unqualified]**` |
| **Command type** | Text |
| **Business object** | `clsXDocument` |
| **Criteria property** | `InsertSQL` |
| **Lifecycle method** | `BeforeInsert` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:CopiesCount` | Input | Decimal | — | Number of copies (defaults to `1` in `Create()`) |
| `:DocumentTypeCode` | Input | String (SmartString) | 5 | Document type code |
| `:EmailAddress` | Input | String (SmartString) | 60 | Email routing address |
| `:FaxNum` | Input | String (SmartString) | 60 | Fax routing number |
| `:FileName` | Input | String | 120 | Print job file name |
| `:IdxContentsText` | Input | String (SmartString) | 2000 | Indexed contents/imaging text |
| `:Sort0Value` | Input | String (SmartString) | 120 | Sort column 0 |
| `:Sort1Value` | Input | String (SmartString) | 120 | Sort column 1 |
| `:Sort2Value` | Input | String (SmartString) | 120 | Sort column 2 |
| `:Sort3Value` | Input | String (SmartString) | 120 | Sort column 3 |
| `:Sort4Value` | Input | String (SmartString) | 120 | Sort column 4 |
| `:Sort5Value` | Input | String (SmartString) | 120 | Sort column 5 |
| `:Sort6Value` | Input | String (SmartString) | 120 | Sort column 6 |
| `:Sort7Value` | Input | String (SmartString) | 120 | Sort column 7 |
| `:Sort8Value` | Input | String (SmartString) | 120 | Sort column 8 |
| `:Sort9Value` | Input | String (SmartString) | 120 | Sort column 9 |
| `:StartValue` | Input | String (SmartString) | 120 | Start-of-document marker value |
| `:XBinTypeCode` | Input | String (SmartString) | 5 | Bin routing type code (defaults to `"AUTO"` in `Create()`) |
| `:XDocumentSeqNum` | Input | Decimal | — | Primary key, generated via `GetNextSeqNum("XDOCUMENT_SEQ")` |
| `:XPrintControlSeqNum` | Input | Decimal | — | FK to `XPRINT_CONTROL` batch header |
| `:PrintGroupText` | Input | String | 60 | Print group label used to batch documents together |
| `:DuplexCode` | Input | String | 5 | Duplex printing code |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [XDOCUMENT](../database-tables.md#xdocument) | INSERT | `COPIES_COUNT`, `DOCUMENT_TYPE_CODE`, `EMAIL_ADDRESS`, `FAX_NUM`, `FILE_NAME`, `IDX_CONTENTS_TEXT`, `SORT0_VALUE`–`SORT9_VALUE`, `START_VALUE`, `XBIN_TYPE_CODE`, `XDOCUMENT_SEQ_NUM`, `XPRINT_CONTROL_SEQ_NUM`, `PRINT_GROUP_TEXT`, `DUPLEX_CODE` |

## Sample SQL

```sql
INSERT INTO XDOCUMENT (
    COPIES_COUNT,
    DOCUMENT_TYPE_CODE,
    EMAIL_ADDRESS,
    FAX_NUM,
    FILE_NAME,
    IDX_CONTENTS_TEXT,
    SORT0_VALUE,
    SORT1_VALUE,
    SORT2_VALUE,
    SORT3_VALUE,
    SORT4_VALUE,
    SORT5_VALUE,
    SORT6_VALUE,
    SORT7_VALUE,
    SORT8_VALUE,
    SORT9_VALUE,
    START_VALUE,
    XBIN_TYPE_CODE,
    XDOCUMENT_SEQ_NUM,
    XPRINT_CONTROL_SEQ_NUM,
    PRINT_GROUP_TEXT,
    DUPLEX_CODE
) VALUES (
    :CopiesCount,
    :DocumentTypeCode,
    :EmailAddress,
    :FaxNum,
    :FileName,
    :IdxContentsText,
    :Sort0Value,
    :Sort1Value,
    :Sort2Value,
    :Sort3Value,
    :Sort4Value,
    :Sort5Value,
    :Sort6Value,
    :Sort7Value,
    :Sort8Value,
    :Sort9Value,
    :StartValue,
    :XBinTypeCode,
    :XDocumentSeqNum,
    :XPrintControlSeqNum,
    :PrintGroupText,
    :DuplexCode
)
```

## Operations and processes
- [Create a print batch with documents](../operations/create-print-batch-with-documents.md)

## Business rules
- [BR-001: Row-count contention check](../business-rules.md#br-001-row-count-contention-check)
- [BR-005: Default bin type on document creation](../business-rules.md#br-005-default-bin-type-on-document-creation)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Services\SAIF.Services.Printing.Remote\clsXDocument.vb`
