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

# SQL-027: Create DocumentTemplateOutputProfile via AddTemplateOutputProfiles

This ORM statement performs a create operation on `DocumentTemplateOutputProfile` via `AddTemplateOutputProfiles`, executed from `Services/SAIF.Services/Documents/TemplateSearchService.cs` (L801).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `DOCUMENT_TEMPLATE_OP_SEQ.NEXTVAL` |
| `:DocumentTemplateSeqNum` | Input | `long` | N/A |  |
| `:CreateUser` | Input | `string` | N/A |  |
| `:CreateDate` | Input | `DateTime` | N/A |  |
| `:DocumentOutputProfileCode` | Input | `DocumentOutputProfileCode` | N/A | Identifier of the referenced `DocumentOutputProfileCode` entity (`References(x => x.DocumentOutputProfileCode)`) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [DOCUMENT_TEMPLATE_OP](../database-tables.md#document_template_op) | INSERT | DOCUMENT_TEMPLATE_OP_SEQ_NUM, DOCUMENT_TEMPLATE_SEQ_NUM, CREATE_USER, CREATE_DATE, DOCUMENT_OP_CODE (identifier from sequence `DOCUMENT_TEMPLATE_OP_SEQ.NEXTVAL`) |

## LINQ statement

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

```csharp
// Services/SAIF.Services/Documents/TemplateSearchService.cs:801
unitOfWork.GetRepository<DocumentTemplateOutputProfile>().Add(newTemplateOp);
```

## 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 DOCUMENT_TEMPLATE_OP_SEQ.NEXTVAL
FROM DUAL

INSERT INTO DOCUMENT_TEMPLATE_OP (
  DOCUMENT_TEMPLATE_OP_SEQ_NUM,
  DOCUMENT_TEMPLATE_SEQ_NUM,
  CREATE_USER,
  CREATE_DATE,
  DOCUMENT_OP_CODE)
VALUES (
  :Id,
  :DocumentTemplateSeqNum,
  :CreateUser,
  :CreateDate,
  :DocumentOutputProfileCode)
```

Translation notes:
- `:Id` is the value fetched from sequence `DOCUMENT_TEMPLATE_OP_SEQ` (`GeneratedBy.Native("DOCUMENT_TEMPLATE_OP_SEQ")`) before the INSERT; NHibernate assigns it to `DocumentTemplateOutputProfile.Id`.
- The mapping declares `.Column(" DOCUMENT_TEMPLATE_SEQ_NUM")` with a leading space; Oracle treats the unquoted identifier as `DOCUMENT_TEMPLATE_SEQ_NUM`.
- Reference FK values are bound from the associated entity's identifier; the referenced tables are **not** read or joined by this statement: `DocumentOutputProfileCode` → `DOCUMENT_OP_CODE` (entity table `DOCUMENT_OP_CODE` not accessed).

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

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

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