---
title: "SQL-021: Create DocumentImagingError via InsertErrorImage"
summary: Create operation against DocumentImagingError via NHibernate ORM.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# SQL-021: Create DocumentImagingError via InsertErrorImage

This ORM statement performs a create operation on `DocumentImagingError` via `InsertErrorImage`, executed from `Services/SAIF.Services/Imaging/McoImageExporter.cs` (L302).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-021 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | N/A (ORM-generated) |
| **Business object** | `DocumentImagingError` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `InsertErrorImage` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `int?` | N/A | Identifier from the `increment` generator |
| `:PdfId` | Input | `int?` | N/A |  |
| `:ClaimNumber` | Input | `string` | N/A |  |
| `:DocType` | Input | `string` | N/A |  |
| `:DocSubType` | Input | `string` | N/A |  |
| `:ErrorDescription` | Input | `string` | N/A |  |
| `:ProcessingDate` | Input | `System.DateTime` | N/A |  |
| `:DocHandle` | Input | `int?` | N/A |  |
| `:CreateDate` | Input | `System.DateTime` | N/A |  |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CLM_DBA.document_imaging_error](../database-tables.md#document_imaging_error) | INSERT | ID, PDF_ID, CLAIM_NUMBER, DOC_TYPE, DOC_SUB_TYPE, ERROR_DESCRIPTION, PROCESSING_DATE, DOCUMENT_HANDLE, CREATE_DATE |

## LINQ statement

Source: `Services/SAIF.Services/Imaging/McoImageExporter.cs:302`.

```csharp
// Services/SAIF.Services/Imaging/McoImageExporter.cs:296
var repository = _unitOfWork.GetRepository<DocumentImagingError>();

// Services/SAIF.Services/Imaging/McoImageExporter.cs:302
repository.Add(imageError);
```

## 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
SELECT MAX(ID)
FROM CLM_DBA.document_imaging_error

INSERT INTO CLM_DBA.document_imaging_error (
  ID,
  PDF_ID,
  CLAIM_NUMBER,
  DOC_TYPE,
  DOC_SUB_TYPE,
  ERROR_DESCRIPTION,
  PROCESSING_DATE,
  DOCUMENT_HANDLE,
  CREATE_DATE)
VALUES (
  :Id,
  :PdfId,
  :ClaimNumber,
  :DocType,
  :DocSubType,
  :ErrorDescription,
  :ProcessingDate,
  :DocHandle,
  :CreateDate)
```

Translation notes:
- `GeneratedBy.Increment()`: NHibernate reads `MAX(ID)` once per session factory and increments the value in memory; `:Id` is that next value (not safe for concurrent writers from other processes).
- A separate projection query `repository.Query().Select(e => e.DocHandle).ToList()` at `McoImageExporter.cs:297` runs before the `Add`; it is its own statement (`SELECT DOC_HANDLE FROM CLM_DBA.document_imaging_error`) and is not part of this Create SQL ID.

## Operations and processes
- McoImageExporter.InsertErrorImage — see [Operations and processes](../operations-processes.md)

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

## Sources
- `Services/SAIF.Services/Imaging/McoImageExporter.cs (L302)`
