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

# SQL-016: Create ClaimNote via CreateTaskNote

This ORM statement performs a create operation on `ClaimNote` via `CreateTaskNote`, executed from `Services/SAIF.Services/Legal/Tasks/LegalTaskService.cs` (L958).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `CLAIM_ACTIVITY_SEQ.NEXTVAL` |
| `:ClaimId` | Input | `long` | N/A |  |
| `:NoteDate` | Input | `DateTime` | N/A |  |
| `:ExternalView` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:Text` | Input | `string` | N/A |  |
| `:CreateUser` | Input | `string` | N/A |  |
| `:CreateDate` | Input | `DateTime` | N/A |  |
| `:UpdateUser` | Input | `string` | N/A |  |
| `:UpdateDate` | Input | `DateTime?` | N/A |  |
| `:UpdateNumber` | Input | `int` | N/A |  |
| `:ClaimNoteCategory` | Input | `ClaimNoteCategory` | N/A | Identifier of the referenced `ClaimNoteCategory` entity (`References(x => x.ClaimNoteCategory)`) |
| `:ClaimNoteType` | Input | `ClaimNoteType` | N/A | Identifier of the referenced `ClaimNoteType` entity (`References(x => x.ClaimNoteType)`) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CLAIM_ACTIVITY](../database-tables.md#claim_activity) | INSERT | CLAIM_ACTIVITY_SEQ_NUM, CLAIM_ID, ACTIVITY_DATE, EXTERNAL_VIEW_FLAG, COMMENT_TEXT, CREATE_USER, CREATE_DATE, UPDATE_USER, UPDATE_DATE, UPDATE_NUM, CLAIM_ACTIVITY_CATEGORY_CODE, CLAIM_ACTIVITY_TYPE_CODE (identifier from sequence `CLAIM_ACTIVITY_SEQ.NEXTVAL`) |

## LINQ statement

Source: `Services/SAIF.Services/Legal/Tasks/LegalTaskService.cs:958`.

```csharp
// Services/SAIF.Services/Legal/Tasks/LegalTaskService.cs:958
_unitOfWork.GetRepository<ClaimNote>().Add(noteData);
```

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

INSERT INTO CLAIM_ACTIVITY (
  CLAIM_ACTIVITY_SEQ_NUM,
  CLAIM_ID,
  ACTIVITY_DATE,
  EXTERNAL_VIEW_FLAG,
  COMMENT_TEXT,
  CREATE_USER,
  CREATE_DATE,
  UPDATE_USER,
  UPDATE_DATE,
  UPDATE_NUM,
  CLAIM_ACTIVITY_CATEGORY_CODE,
  CLAIM_ACTIVITY_TYPE_CODE)
VALUES (
  :Id,
  :ClaimId,
  :NoteDate,
  :ExternalView,
  :Text,
  :CreateUser,
  :CreateDate,
  :UpdateUser,
  :UpdateDate,
  :UpdateNumber,
  :ClaimNoteCategory,
  :ClaimNoteType)
```

Translation notes:
- `:Id` is the value fetched from sequence `CLAIM_ACTIVITY_SEQ` (`GeneratedBy.Native("CLAIM_ACTIVITY_SEQ")`) before the INSERT; NHibernate assigns it to `ClaimNote.Id`.
- `:ExternalView` are bound as `'Y'` / `'N'` (`YesNoType`).
- Reference FK values are bound from the associated entity's identifier; the referenced tables are **not** read or joined by this statement: `ClaimNoteCategory` → `CLAIM_ACTIVITY_CATEGORY_CODE` (entity table `CLAIM_ACTIVITY_CATEGORY_CODE` not accessed); `ClaimNoteType` → `CLAIM_ACTIVITY_TYPE_CODE`.
- `ClaimNoteCategory` (`Code == "LEGAL"`) and `ClaimNoteType` (`Code == "UPDT"`) are obtained by separate `SingleOrDefault` lookups (`LegalTaskService.cs:947-952`); only their FK codes are written here. `ClaimId = taskData.Claim.Id` is a plain value.

## Operations and processes
- LegalTaskService.CreateTaskNote — see [Operations and processes](../operations-processes.md)

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

## Sources
- `Services/SAIF.Services/Legal/Tasks/LegalTaskService.cs (L958)`
