---
title: "SQL-155: Retrieve DocumentDistributionLog via DeleteRequestDistributions"
summary: Read operation against DocumentDistributionLog via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-155: Retrieve DocumentDistributionLog via DeleteRequestDistributions

This ORM statement performs a read operation on `DocumentDistributionLog` via `IUnitOfWork.GetRepository<T>()`, executed from `Services/SAIF.Services/Documents/TemplateSearchService.cs (L858)`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-155 |
| **Operation type** | Read |
| **Execution method** | ORM (NHibernate LINQ) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `DocumentDistributionLog` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `DeleteRequestDistributions` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `requestId` | Input | ** | N/A | `a.DocumentRequestLogSeqNum == requestId` → column DOCUMENT_REQUEST_LOG_SEQ_NUM |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [DOCUMENT_DISTRIBUTION_LOG](../database-tables.md#document_distribution_log) | SELECT | `DOCUMENT_DIST_LOG_SEQ_NUM`, `DOCUMENT_REQUEST_LOG_SEQ_NUM`, `DOC_REQUEST_LOG_STATUS_CODE`, `PLANNED_DISTRIBUTION_DATE`, `ACTUAL_DISTRIBUTION_DATE`, `PACKAGE_NAME`, `XML`, `PRINTER_NAME`, `PRINT_MODE`, `COPIES`, `SCALE_MODE`, `OUTPUT_PROFILE`, `IMPORT_INFO`, `EMAIL_INFO`, `FAX_INFO`, `IMAGE_PATH`, `TRAY`, `DEFERRED_INFO`, `CERTIFICATION_INFO`, `APPLICATION`, `CREATE_USER`, `CREATE_DATE`, `UPDATE_USER`, `UPDATE_DATE` |

## LINQ statement

Source: `Services/SAIF.Services/Documents/TemplateSearchService.cs:858`

```csharp
// Services/SAIF.Services/Documents/TemplateSearchService.cs:858-859
            IEnumerable<DocumentDistributionLog> logs = unitOfWork.GetRepository<DocumentDistributionLog>().Query()
                                                      .Where(a => a.DocumentRequestLogSeqNum == requestId);

// Services/SAIF.Services/Documents/TemplateSearchService.cs:863-865
                foreach (var log in logs)
                {
                    unitOfWork.GetRepository<DocumentDistributionLog>().Delete(log);
```

## Sample SQL

> **Inferred SQL:** This SQL was inferred from the LINQ statement above and the NHibernate mappings. It is not concrete SQL from source code; NHibernate generates the executed statement at runtime, so aliases, column order, join syntax, and bind-parameter names may differ.

```sql
-- Inferred from LINQ (NHibernate mapping translation); not concrete SQL
-- Services/SAIF.Services/Documents/TemplateSearchService.cs:858
SELECT
  DDL.DOCUMENT_DIST_LOG_SEQ_NUM,
  DDL.DOCUMENT_REQUEST_LOG_SEQ_NUM,
  DDL.DOC_REQUEST_LOG_STATUS_CODE,
  DDL.PLANNED_DISTRIBUTION_DATE,
  DDL.ACTUAL_DISTRIBUTION_DATE,
  DDL.PACKAGE_NAME,
  DDL.XML,
  DDL.PRINTER_NAME,
  DDL.PRINT_MODE,
  DDL.COPIES,
  DDL.SCALE_MODE,
  DDL.OUTPUT_PROFILE,
  DDL.IMPORT_INFO,
  DDL.EMAIL_INFO,
  DDL.FAX_INFO,
  DDL.IMAGE_PATH,
  DDL.TRAY,
  DDL.DEFERRED_INFO,
  DDL.CERTIFICATION_INFO,
  DDL.APPLICATION,
  DDL.CREATE_USER,
  DDL.CREATE_DATE,
  DDL.UPDATE_USER,
  DDL.UPDATE_DATE
FROM DOCUMENT_DISTRIBUTION_LOG DDL
WHERE DDL.DOCUMENT_REQUEST_LOG_SEQ_NUM = :requestId
```

Translation notes:
- Enumerated by `foreach` (L863); each row is then passed to `Delete(log)` (L865) - per-row DELETE statements are separate CRUD operations not documented under this SQL ID.
- `logs.IsNull()` (L860) is an in-memory check on the un-materialized queryable, not SQL.

## Operations and processes
- TemplateSearchService.DeleteRequestDistributions — see [Operations and processes](../operations-processes.md)

## Sources
- `Services/SAIF.Services/Documents/TemplateSearchService.cs (L858)`
