---
title: "SQL-012: Insert IMGSYS row"
summary: Inserts a new IMGSYS imaging system record with a pre-generated TOWID.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-012: Insert IMGSYS row

This statement inserts a new row into the `IMGSYS` table, creating an imaging system record that owns the TOWID reference key used by IMAGE rows. `SCANDT` and `UPDTTS` are set using Oracle `sysdate`. `AfterInsert` verifies exactly one row was affected.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-012 |
| **Operation type** | Create |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text** |
| **Business object** | `clsImgsys` |
| **Criteria property** | `InsertSQL` |
| **Lifecycle method** | `BeforeInsert` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:Batid` | Input | [not specified]** | 15 | Batch identifier. |
| `:Crtrid` | Input | [not specified]** | 30 | Creator user ID. |
| `:Delcd` | Input | [not specified]** | 5 | Delete code. |
| `:Idxfl` | Input | [not specified]** | 1 | Indexed flag (Y/N). |
| `:Ifnds` | Input | [not specified]** | N/A | Image find date start. |
| `:Ifnid` | Input | [not specified]** | N/A | Image find ID. |
| `:Npages` | Input | [not specified]** | N/A | Number of pages. |
| `:Slevel` | Input | [not specified]** | N/A | Security level. |
| `:Towid` | Input | [not specified]** | N/A | TOWID primary key (from SQL-003). |
| `:Updrid` | Input | [not specified]** | 30 | Last updater user ID. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMGSYS](../database-tables.md#imgsys) | INSERT | BATID, CRTRID, DELCD, IDXFL, IFNDS, IFNID, NPAGES, SCANDT, SLEVEL, TOWID, UPDRID, UPDTTS |

## Sample SQL

```sql
Insert into IMGSYS (
    BATID, CRTRID, DELCD, IDXFL,
    IFNDS, IFNID, NPAGES, SCANDT,
    SLEVEL, TOWID, UPDRID, UPDTTS
) Values (
    :Batid, :Crtrid, :Delcd, :Idxfl,
    :Ifnds, :Ifnid, :Npages, sysdate,
    :Slevel, :Towid, :Updrid, sysdate
)
```

## Operations and processes
- [Imaging system management](../operations/imaging-system-management.md)

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

## Sources
- `Business\SAIF.Business.Imaging\clsImgsys.vb`
