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

# SQL-006: Create CbpAuthorization via CreateAuthorization

This ORM statement performs a create operation on `CbpAuthorization` via `CreateAuthorization`, executed from `Services/SAIF.Services/Claims/Bills/AuthorizationService.cs` (L262).

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Id` | Input | `long` | N/A | Identifier from `CBP_AUTHORIZATION_SEQ.NEXTVAL` |
| `:UpdateNumber` | Input | `int` | N/A | Version column (`Version()`); NHibernate writes its initial value |
| `:ClaimId` | Input | `long` | N/A |  |
| `:ReceivedTimelyFlagCode` | Input | `string` | N/A |  |
| `:FromDate` | Input | `DateTime` | N/A |  |
| `:ThruDate` | Input | `DateTime` | N/A |  |
| `:MaximumVisits` | Input | `int` | N/A |  |
| `:UpdateDate` | Input | `DateTime` | N/A |  |
| `:UpdateUser` | Input | `string` | N/A |  |
| `:AuthorizationType` | Input | `CbpAuthorizationTypeCode` | N/A | Identifier of the referenced `CbpAuthorizationTypeCode` entity (`References(x => x.AuthorizationType)`) |
| `:ServicePmGroup` | Input | `CbpServicePmGroupCode` | N/A | Identifier of the referenced `CbpServicePmGroupCode` entity (`References(x => x.ServicePmGroup)`) |
| `:BillingProvider` | Input | `ProviderLocation` | N/A | Identifier of the referenced `ProviderLocation` entity (`References(x => x.BillingProvider)`) |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CBP_AUTHORIZATION](../database-tables.md#cbp_authorization) | INSERT | CBP_AUTHORIZATION_SEQ_NUM, UPDATE_NUM, CLAIM_ID, RECEIVED_TIMELY_FLAG_CODE, AUTH_FROM_DATE, AUTH_THRU_DATE, MAXIMUM_VISITS_QTY, UPDATE_DATE, UPDATE_USER, CBP_AUTHORIZATION_TYPE_CODE, CBP_SERVICE_PM_GROUP_CODE, BILL_PROVIDER_LOCATION_SEQ_NUM (identifier from sequence `CBP_AUTHORIZATION_SEQ.NEXTVAL`) |

## LINQ statement

Source: `Services/SAIF.Services/Claims/Bills/AuthorizationService.cs:262`.

```csharp
// Services/SAIF.Services/Claims/Bills/AuthorizationService.cs:262
unitOfWork.GetRepository<CbpAuthorization>().Add(authorize);
```

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

INSERT INTO CBP_AUTHORIZATION (
  CBP_AUTHORIZATION_SEQ_NUM,
  UPDATE_NUM,
  CLAIM_ID,
  RECEIVED_TIMELY_FLAG_CODE,
  AUTH_FROM_DATE,
  AUTH_THRU_DATE,
  MAXIMUM_VISITS_QTY,
  UPDATE_DATE,
  UPDATE_USER,
  CBP_AUTHORIZATION_TYPE_CODE,
  CBP_SERVICE_PM_GROUP_CODE,
  BILL_PROVIDER_LOCATION_SEQ_NUM)
VALUES (
  :Id,
  :UpdateNumber,
  :ClaimId,
  :ReceivedTimelyFlagCode,
  :FromDate,
  :ThruDate,
  :MaximumVisits,
  :UpdateDate,
  :UpdateUser,
  :AuthorizationType,
  :ServicePmGroup,
  :BillingProvider)
```

Translation notes:
- `:Id` is the value fetched from sequence `CBP_AUTHORIZATION_SEQ` (`GeneratedBy.Native("CBP_AUTHORIZATION_SEQ")`) before the INSERT; NHibernate assigns it to `CbpAuthorization.Id`.
- `UPDATE_NUM` is the optimistic-concurrency version column (`Version(x => x.UpdateNumber)`); NHibernate sets its initial value on INSERT.
- Reference FK values are bound from the associated entity's identifier; the referenced tables are **not** read or joined by this statement: `AuthorizationType` → `CBP_AUTHORIZATION_TYPE_CODE` (entity table `CBP_AUTHORIZATION_TYPE_CODE` not accessed); `ServicePmGroup` → `CBP_SERVICE_PM_GROUP_CODE` (entity table `CBP_SERVICE_PM_GROUP_CODE` not accessed); `BillingProvider` → `BILL_PROVIDER_LOCATION_SEQ_NUM` (entity table `PROVIDER_LOCATION` not accessed).
- Cascade: `HasMany(x => x.CptCodes)` is mapped with `Cascade.AllDeleteOrphan()`; any transient instances in that association are saved in their own statements (not fabricated here).
- `BillingProvider` is obtained by a separate `ProviderLocation` `SingleOrDefault(x => x.Id == authorization.BillingProviderId)` query (`AuthorizationService.cs:256-259`); that lookup is its own SQL statement. This INSERT only writes the FK value.

## Operations and processes
- AuthorizationService.CreateAuthorization — see [Operations and processes](../operations-processes.md)

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

## Sources
- `Services/SAIF.Services/Claims/Bills/AuthorizationService.cs (L262)`
