---
title: "SQL-044: Soft-delete IMGSYS batch rows"
summary: Implements a soft delete by setting the DELCD column on non-indexed IMGSYS rows matching a batch ID, rather than physically removing them.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-044: Soft-delete IMGSYS batch rows

This statement implements a soft delete on `IMGSYS` by setting `DELCD` to a configured delete code, updating `UPDTTS` to `sysdate` and `UPDRID` to the updater ID. It targets non-indexed (`IDXFL = 'N'`), non-deleted (`DELCD = ' '`) rows matching the specified batch ID. A CASE expression handles null batch IDs as a space-padded match. Executed by `clsIndexBatch.BeforeDelete`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-044 |
| **Operation type** | Delete |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text** |
| **Business object** | `clsIndexBatch` |
| **Criteria property** | `DeleteSQL` |
| **Lifecycle method** | `BeforeDelete` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:DefaultDelCd` | Input | [not specified]** | 3 | The delete code to set (soft-delete marker). |
| `:UpdrId` | Input | [not specified]** | 15 | Updater user ID. |
| `:BatchID1` | Input | [not specified]** | 15 | Batch ID (null check for CASE expression). |
| `:BatchID2` | Input | [not specified]** | 15 | Batch ID (CASE branch value). |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMGSYS](../database-tables.md#imgsys) | UPDATE (soft delete) | DELCD, UPDTTS, UPDRID (WHERE: IDXFL, BATID, DELCD) |

## Sample SQL

```sql
update imgsys imgsys
set
    delcd = :DefaultDelCd,
    updtts = sysdate,
    updrid = :updrid
where nvl(idxfl,'N') = 'N'
  and nvl(batid,' ') = case
        when :BatchID1 is null then ' '
        else :BatchID2
      end
  and nvl(delcd,' ') = ' '
```

## 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\clsIndexBatch.vb`
