---
title: "SQL-012: clsXDocumentCollection.RetrievePrintSQL"
summary: Retrieves distinct print groups for a batch (ByPrintGroup mode) — supplemental non-interface property.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Services.Printing.Remote
reference_type: package
---

# SQL-012: clsXDocumentCollection.RetrievePrintSQL

Retrieves distinct print groups for a print-control batch using `SELECT DISTINCT` keyed on `PRINT_GROUP_TEXT`. This is a supplemental property (`RetrievePrintSQL`) that is not part of the `IBusinessCriteria` interface. It is selected by `BeforeRetrieve` when `PrintType = ByPrintGroup`, collapsing per-document rows to group-level entries for "print as one group" scenarios. Literal placeholder values (`'n/a'`, `1`, `0`) are used for columns not relevant to group-level printing.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-012 |
| **Operation type** | Read (Retrieve) |
| **Execution method** | Inline (supplemental property, not part of `IBusinessCriteria`) |
| **Database** | Oracle |
| **Schema** | `[unqualified]**` |
| **Command type** | Text |
| **Business object** | `clsXDocumentCollection` |
| **Criteria property** | `RetrievePrintSQL` |
| **Lifecycle method** | `BeforeRetrieve` (`PrintType = ByPrintGroup`) |

## Parameters

Parameters are shared with SQL-011 — both are bound once in `BeforeRetrieve` and the appropriate SQL is selected based on `PrintType`:

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:XPrintControlSeqNum` | Input | Decimal | — | Batch-header filter — same as SQL-011 |
| `:PrinterID` | Input | String | 30 | Printer filter — same as SQL-011 |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [XDOCUMENT](../database-tables.md#xdocument) | SELECT (DISTINCT) | `XPRINT_CONTROL_SEQ_NUM`, `XBIN_TYPE_CODE`, `DUPLEX_CODE`, `PRINT_GROUP_TEXT` |
| [XPRINTER_BIN](../database-tables.md#xprinter_bin) | JOIN | `PRINTER_ID`, `XBIN_TYPE_CODE`, `BIN_NUM` |
| [XPRINTER](../database-tables.md#xprinter) | JOIN | `PRINTER_ID`, `NETWORK_NAME` |

## Sample SQL

```sql
Select Distinct
    1                                       as CopiesCount,
    'n/a'                                   as DocumentTypeCode,
    'n/a'                                   as EmailAddress,
    'n/a'                                   as FaxNum,
    XDOCUMENT.PRINT_GROUP_TEXT              as FileName,
    'n/a'                                   as IdxContentsText,
    'n/a'                                   as Sort0Value,
    'n/a'                                   as Sort1Value,
    'n/a'                                   as Sort2Value,
    'n/a'                                   as Sort3Value,
    'n/a'                                   as Sort4Value,
    'n/a'                                   as Sort5Value,
    'n/a'                                   as Sort6Value,
    'n/a'                                   as Sort7Value,
    'n/a'                                   as Sort8Value,
    'n/a'                                   as Sort9Value,
    'n/a'                                   as StartValue,
    XDOCUMENT.XBIN_TYPE_CODE                as XBinTypeCode,
    0                                       as XDocumentSeqNum,
    XDOCUMENT.XPRINT_CONTROL_SEQ_NUM        as XPrintControlSeqNum,
    XPRINTER_BIN.BIN_NUM                    as XBinNumber,
    XPRINTER.NETWORK_NAME                   as PrinterNetworkName,
    XDOCUMENT.DUPLEX_CODE                   as DuplexCode
From
    XDOCUMENT, XPRINTER_BIN, XPRINTER
Where
    XDOCUMENT.XPRINT_CONTROL_SEQ_NUM = :XPrintControlSeqNum
    AND XPRINTER_BIN.PRINTER_ID = :PrinterID
    AND XPRINTER_BIN.PRINTER_ID = XPRINTER.PRINTER_ID
    AND XDOCUMENT.XBIN_TYPE_CODE = XPRINTER_BIN.XBIN_TYPE_CODE
ORDER BY
    XDOCUMENT.PRINT_GROUP_TEXT
```

## Operations and processes
- [Retrieve documents for printing](../operations/retrieve-documents-for-printing.md)

## Business rules
- [BR-004: Duplex mode controlled vocabulary](../business-rules.md#br-004-duplex-mode-controlled-vocabulary)

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

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