---
title: "SQL-023: Ebill batch status update to Completed (EbillBatch)"
summary: Sets a batch's status to the COMP status code; persisted by NHibernate dirty-check detection at flush.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Domain
reference_type: package
---

# SQL-023: Ebill batch status update to Completed (EbillBatch)

`Batch.SetBatchToCompleted` sets the batch's `Status` property to the "COMP" status code, one of the eight status setters (COMP/EXTR/IMAGE/INDEX/EOB/DLOAD/ACK/SETUP) defined on `Batch`. The `UPDATE` runs via NHibernate dirty-check detection when the caller's `IUnitOfWork` flushes*.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-023 |
| **Operation type** | Update* |
| **Execution method** | ORM (dirty-check flush*) |
| **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** | `SetBatchToCompleted` |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [EBILL_BATCH](../database-tables.md#ebill_batch) | UPDATE | `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`, `EBILL_BATCH_SEQ_NUM` |

## LINQ statement

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

```csharp
// Domain/SAIF.Domain/Model/Claims/Ebilling/Batch.cs:187-191
public void SetBatchToCompleted()
{
    DataItem.Status = _ebillingQueryProvider.BatchQueries.GetBatchStatus("COMP");
    SetUpdateInfo();
}

// Domain/SAIF.Domain/Model/Claims/Ebilling/Batch.cs:234-238
private void SetUpdateInfo()
{
    Data.UpdateDate = DateTime.Now;
    Data.UpdateUser = profileService.GetCurrentUser().UserId;
}
```

## 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
UPDATE EBILL_BATCH
SET
  UPDATE_NUM = :newVersion,
  CREATE_DATE = :CreateDate,
  SUBMISSION_DATE = :SubmissionDate,
  UPDATE_DATE = :UpdateDate,
  UPDATE_USER = :UpdateUser,
  CLEARINGHOUSE_FILE_NAME = :ClearinghouseFileName,
  EBILL_BATCH_TYPE_CODE = :Type,
  RESPONSE_BATCH_SEQ_NUM = :ResponseBatch,
  EBILL_BATCH_STATUS_CODE = :Status,
  PAYMENT_TRANS_STAT_SEQ_NUM = :PaymentStatistic,
  EBILL_CLEARINGHOUSE_SEQ_NUM = :Clearinghouse
WHERE EBILL_BATCH_SEQ_NUM = :Id
  AND UPDATE_NUM = :oldVersion
```

Translation notes:
- No explicit `Update()` call: under the stateful strategy `RepositoryBase.Update` is a no-op and the UPDATE is emitted by NHibernate dirty-checking at `Commit()` flush (Legends: SAIF.Framework.Data.NHibernate RepositoryBase / business-rules). The mapping declares no `DynamicUpdate()`, so NHibernate sends every updatable mapped column, not only the ones changed here.
- Version `UPDATE_NUM` (`EbillBatchMap.cs:12`): `SET UPDATE_NUM = :newVersion ... AND UPDATE_NUM = :oldVersion`.
- Bind variables for `References` carry the referenced entity's identifier; values not changed by this call site are re-sent unchanged.
- The C# code assigns `DateTime.Now` client-side before flush; the value is bound as an ordinary parameter (no server date function).
- `GetBatchStatus("COMP")` is a separate read; `:Status` carries status code `COMP`. The sibling `SetBatchTo*` methods (lines 193-227) produce the same UPDATE shape with other codes.
- Prior page named the column `STATUS`; the mapped column is `EBILL_BATCH_STATUS_CODE` (`EbillBatchMap.cs:15`).

## Operations and processes
- OP-DOM-09 Batch lifecycle — status setters COMP, EXTR, IMAGE, INDEX, EOB, DLOAD, ACK, SETUP (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
