---
title: "SQL-003: Batch insert (EbillBatch, basic constructor)"
summary: Creates a new EbillBatch with status NEW using the type/submission-date/file-name constructor overload.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-003: Batch insert (EbillBatch, basic constructor)

The basic `Batch` constructor builds a new `EbillBatch` with status "NEW", the supplied type, submission date (defaulting to the current date), and clearinghouse file name, then adds it to the repository.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-003 |
| **Operation type** | Create |
| **Execution method** | ORM (IRepository.Add) |
| **Database** | Oracle* |
| **Schema** | [unqualified]** |
| **Command type** | N/A — ORM (NHibernate generates SQL at runtime from the ClassMaps in `Data/SAIF.Data.NHibernate/Mappings/**`) |
| **Business object** | `Batch` |
| **Criteria property** | N/A — ORM |
| **Lifecycle method** | `Batch` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EBILL_BATCH](../database-tables.md#ebill_batch) | INSERT | `EBILL_BATCH_SEQ_NUM`, `UPDATE_NUM`, `CREATE_DATE`, `SUBMISSION_DATE`, `UPDATE_DATE`, `UPDATE_USER`, `CLEARINGHOUSE_FILE_NAME`, `EBILL_BATCH_TYPE_CODE`, `RESPONSE_BATCH_SEQ_NUM`, `EBILL_BATCH_STATUS_CODE`, `PAYMENT_TRANS_STAT_SEQ_NUM`, `EBILL_CLEARINGHOUSE_SEQ_NUM` |

## LINQ statement

Source: `Domain/SAIF.Domain/Model/Claims/Ebilling/Batch.cs:41`

```csharp
// Domain/SAIF.Domain/Model/Claims/Ebilling/Batch.cs:30-41
DataItem = new EbillBatch()
{
    Type = type,
    Status = _ebillingQueryProvider.BatchQueries.GetBatchStatus("NEW"),
    ClearinghouseFileName = fileName,
    SubmissionDate = (submissionDate == default(DateTime)) ? currentDate : submissionDate,
    CreateDate = currentDate,
    UpdateDate = currentDate,
    UpdateUser = profileService.GetCurrentUser().UserId
};

Factory.GetRepository<EbillBatch>().Add(DataItem);
```

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

INSERT INTO EBILL_BATCH (
  EBILL_BATCH_SEQ_NUM,
  UPDATE_NUM,
  CREATE_DATE,
  SUBMISSION_DATE,
  UPDATE_DATE,
  UPDATE_USER,
  CLEARINGHOUSE_FILE_NAME,
  EBILL_BATCH_TYPE_CODE,
  RESPONSE_BATCH_SEQ_NUM,
  EBILL_BATCH_STATUS_CODE,
  PAYMENT_TRANS_STAT_SEQ_NUM,
  EBILL_CLEARINGHOUSE_SEQ_NUM)
VALUES (
  :Id,
  :UpdateNumber,
  :CreateDate,
  :SubmissionDate,
  :UpdateDate,
  :UpdateUser,
  :ClearinghouseFileName,
  :Type,
  :ResponseBatch,
  :Status,
  :PaymentStatistic,
  :Clearinghouse)
```

Translation notes:
- `:Id` is the value fetched from `EBILL_BATCH_SEQ` (`GeneratedBy.Native("EBILL_BATCH_SEQ")` on Oracle).
- `:UpdateNumber` is the initial version value NHibernate seeds on insert (version column mapped with `Version(...)`).
- Reference bind variables (`:<Property>`) carry the referenced entity's identifier value.
- The C# code assigns `DateTime.Now` client-side before flush; the value is bound as an ordinary parameter (no server date function).
- Constructor without clearinghouse: `:Clearinghouse`, `:ResponseBatch`, `:PaymentStatistic` are NULL; `:ClearinghouseFileName` = `fileName` (default `""`).
- `Status` is obtained from `GetBatchStatus("NEW")` — a separate query-provider read, not part of this SQL ID.

## Operations and processes
- OP-DOM-09 Batch lifecycle — Create sets status NEW and inserts `EbillBatch` (see [Operations and processes](../operations-processes.md))

## Business rules
- [DOM-BR-090](../business-rules.md#dom-br-090-batch-create)
- [DOM-BR-091](../business-rules.md#dom-br-091-getbatch)
- [DOM-BR-092](../business-rules.md#dom-br-092-status-set)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- Domain/SAIF.Domain/Model/Claims/Ebilling/Batch.cs
