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

# SQL-018: Create Debtor via CreateDebtor

This ORM statement performs a create operation on `Debtor` via `CreateDebtor`, executed from `Services/SAIF.Services/Collections/CollectionsService.cs` (L589).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `LEGAL_COLL_DEBTOR_SEQ.NEXTVAL` |
| `:UpdateNum` | Input | `int` | N/A | Version column (`Version()`); NHibernate writes its initial value |
| `:IsStatementHeld` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:LastStatementDate` | Input | `DateTime?` | N/A |  |
| `:IsIncludedOnSoil` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:SoilEffectiveDate` | Input | `DateTime?` | N/A |  |
| `:SoilExpirationDate` | Input | `DateTime?` | N/A |  |
| `:DebtorSSN` | Input | `string` | N/A |  |
| `:AffiliateId` | Input | `string` | N/A |  |
| `:LocID` | Input | `long?` | N/A |  |
| `:WorkerID` | Input | `long?` | N/A |  |
| `:ThirdPartyID` | Input | `long?` | N/A |  |
| `:UpdateUser` | Input | `string` | N/A |  |
| `:UpdateDate` | Input | `DateTime` | N/A |  |
| `:IsBusinessAffiliate` | Input | `bool` | N/A | Bound as `'Y'`/`'N'` (`YesNoType`) |
| `:LastStatementBalanceAmount` | Input | `decimal` | N/A |  |
| `:LastName` | Input | `string` | N/A |  |
| `:FirstName` | Input | `string` | N/A |  |
| `:MiddleInitial` | Input | `string` | N/A |  |
| `:Suffix` | Input | `string` | N/A |  |
| `:CorporationName` | Input | `string` | N/A |  |
| `:Case` | Input | `Case` | N/A | Identifier of the referenced `Case` entity (`References(x => x.Case)`) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [LEGAL_COLLECTION_DEBTOR](../database-tables.md#legal_collection_debtor) | INSERT | LEGAL_COLL_DEBTOR_SEQ_NUM, UPDATE_NUM, HOLD_STATEMENT_FLAG, LAST_STATEMENT_DATE, INCLUDE_ON_SOIL_FLAG, SOIL_EFF_DATE, SOIL_EXP_DATE, DEBTOR_SSN, AFFILIATE_ID, LOC_SEQ_NUM, WORKER_ID, THIRD_PARTY_SEQ_NUM, UPDATE_USER, UPDATE_DATE, BUSINESS_AFFILIATE_FLAG, LAST_STATEMENT_BALANCE_AMT, LAST_NAME, FIRST_NAME, MIDDLE_INITIAL, SUFFIX, CORPORATION_NAME, LEGAL_COLLECTION_SEQ_NUM (identifier from sequence `LEGAL_COLL_DEBTOR_SEQ.NEXTVAL`) |

## LINQ statement

Source: `Services/SAIF.Services/Collections/CollectionsService.cs:589`.

```csharp
// Services/SAIF.Services/Collections/CollectionsService.cs:589
UnitOfWork.GetRepository<DataModel.Debtor>().Add(debtorData);
```

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

INSERT INTO LEGAL_COLLECTION_DEBTOR (
  LEGAL_COLL_DEBTOR_SEQ_NUM,
  UPDATE_NUM,
  HOLD_STATEMENT_FLAG,
  LAST_STATEMENT_DATE,
  INCLUDE_ON_SOIL_FLAG,
  SOIL_EFF_DATE,
  SOIL_EXP_DATE,
  DEBTOR_SSN,
  AFFILIATE_ID,
  LOC_SEQ_NUM,
  WORKER_ID,
  THIRD_PARTY_SEQ_NUM,
  UPDATE_USER,
  UPDATE_DATE,
  BUSINESS_AFFILIATE_FLAG,
  LAST_STATEMENT_BALANCE_AMT,
  LAST_NAME,
  FIRST_NAME,
  MIDDLE_INITIAL,
  SUFFIX,
  CORPORATION_NAME,
  LEGAL_COLLECTION_SEQ_NUM)
VALUES (
  :Id,
  :UpdateNum,
  :IsStatementHeld,
  :LastStatementDate,
  :IsIncludedOnSoil,
  :SoilEffectiveDate,
  :SoilExpirationDate,
  :DebtorSSN,
  :AffiliateId,
  :LocID,
  :WorkerID,
  :ThirdPartyID,
  :UpdateUser,
  :UpdateDate,
  :IsBusinessAffiliate,
  :LastStatementBalanceAmount,
  :LastName,
  :FirstName,
  :MiddleInitial,
  :Suffix,
  :CorporationName,
  :Case)
```

Translation notes:
- `:Id` is the value fetched from sequence `LEGAL_COLL_DEBTOR_SEQ` (`GeneratedBy.Native("LEGAL_COLL_DEBTOR_SEQ")`) before the INSERT; NHibernate assigns it to `Debtor.Id`.
- `UPDATE_NUM` is the optimistic-concurrency version column (`Version(x => x.UpdateNum)`); NHibernate sets its initial value on INSERT.
- `:IsStatementHeld`, `:IsIncludedOnSoil`, `:IsBusinessAffiliate` 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: `Case` → `LEGAL_COLLECTION_SEQ_NUM` (entity table `LEGAL_COLLECTION` not accessed).

## Operations and processes
- CollectionsService.CreateDebtor — see [Operations and processes](../operations-processes.md)

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

## Sources
- `Services/SAIF.Services/Collections/CollectionsService.cs (L589)`
