---
title: "SQL-002: Oracle sequence-based ID generation for ImageSystem"
summary: Fetches the next value of the tower_seq Oracle sequence for a new ImageSystem entity.
status: draft
owner: Framework
last_reviewed: 2026-09-15
library: SAIF.Framework.Data.NHibernate
reference_type: package
---

# SQL-002: Oracle sequence-based ID generation for ImageSystem

This statement is a direct SQL escape hatch used by `ImageRepositoryExtensions.GetNextTowId` to obtain the next `long` value of the `tower_seq` Oracle sequence, bypassing the mapped-entity ID-generation path (the `ImageSystem` entity's `TOWID` identity column has no `GeneratedBy` clause, so this call is its only path to an ID).

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-002 |
| **Operation type** | Sequence |
| **Execution method** | Inline SQL (`ISessionStrategy.CreateSqlQuery`) |
| **Database** | Oracle |
| **Schema** | `[unqualified]**` |
| **Command type** | Text |
| **Business object** | `ImageSystem` (via `IRepository<ImageSystem>` extension) |
| **Criteria property** | N/A — no `IBusinessCriteria` exists in this library |
| **Lifecycle method** | `ImageRepositoryExtensions.GetNextTowId` |

## Parameters

No parameters — this is a literal, parameterless sequence-name query with no bind variables.

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMGSYS](../database-tables.md#imgsys) | SELECT (sequence value only; no table row read) | — (`tower_seq.nextval`, no column reference) |

## Sample SQL

```sql
select tower_seq.nextval
from dual
```

## Operations and processes
- [Oracle sequence based ID generation (Imaging domain)](../operations-processes.md#oracle-sequence-based-id-generation-imaging-domain)

## Business rules
No business rule governs this statement directly — the sequence read is unconditional. The generated value's use is governed by [BR-005](../business-rules.md#br-005-repository-is-scoped-to-one-unit-of-work) once the caller assigns it to a new `ImageSystem` and calls `Add()`.

## Sources
- `Repositories/Imaging/ImageRepositoryExtensions.cs`
