---
title: "SQL-014: clsXPrintControlCollection.RetrieveSQL"
summary: Retrieves unprocessed or stale print-control batch headers for cleanup.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Services.Printing.Remote
reference_type: package
---

# SQL-014: clsXPrintControlCollection.RetrieveSQL

Retrieves `XPRINT_CONTROL` rows whose `PROCESSED_DATE` is before a given cutoff or whose `CREATE_DATE` is more than 30 days old. This query drives the pending-processing and stale-batch-cleanup workflow. The 30-day threshold is set in `Criteria.New` as `ThirtyDaysAgoDate = Today.AddDays(-30)`. Staleness logic is governed by [BR-003](../business-rules.md#br-003-print-control-batch-staleness-rule).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:ProcessedDate` | Input | Date | — | Batches processed before this date are eligible |
| `:ThirtyDaysAgoDate` | Input | Date | — | `Today.AddDays(-30)` — catches stale unprocessed batches regardless of processed status |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [XPRINT_CONTROL](../database-tables.md#xprint_control) | SELECT | `DIRECTORY_NAME`, `DUPLEX_CODE`, `IDM_PATH_NAME`, `MD5_HASH_VALUE`, `PROCESSED_DATE`, `XML_FILE_NAME`, `XPRINT_CONTROL_SEQ_NUM`, `CREATE_DATE` |

## Sample SQL

```sql
Select
    XPRINT_CONTROL.DIRECTORY_NAME           as DirectoryName,
    XPRINT_CONTROL.DUPLEX_CODE              as DuplexCode,
    XPRINT_CONTROL.IDM_PATH_NAME            as IdmPathName,
    XPRINT_CONTROL.MD5_HASH_VALUE           as Md5HashValue,
    XPRINT_CONTROL.PROCESSED_DATE           as ProcessedDate,
    XPRINT_CONTROL.XML_FILE_NAME            as XmlFileName,
    XPRINT_CONTROL.XPRINT_CONTROL_SEQ_NUM   as XprintControlSeqNum
From
    XPRINT_CONTROL
Where
    XPRINT_CONTROL.PROCESSED_DATE < :ProcessedDate
    OR XPRINT_CONTROL.CREATE_DATE < :ThirtyDaysAgoDate
```

## Operations and processes
- [Retrieve print-control batches pending processing](../operations/retrieve-print-control-batches-pending-processing.md)

## Business rules
- [BR-003: Print-control batch staleness rule](../business-rules.md#br-003-print-control-batch-staleness-rule)

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

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