---
title: "SQL-031: Retrieve index batch summary by batch ID"
summary: Retrieves a summary of non-indexed, non-deleted IMGSYS rows for a specific batch ID, returning the count of remaining documents.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-031: Retrieve index batch summary by batch ID

This statement aggregates `IMGSYS` rows for a specific batch ID where `IDXFL = 'N'` (not indexed) and `DELCD = ' '` (not deleted), returning the batch ID, scan date, and count of remaining documents. Executed by `clsIndexBatch.BeforeRetrieve`.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-031 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text** |
| **Business object** | `clsIndexBatch` |
| **Criteria property** | `RetrieveSQL` |
| **Lifecycle method** | `BeforeRetrieve` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:BatchID` | Input | [not specified]** | 15 | The batch ID to retrieve. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMGSYS](../database-tables.md#imgsys) | SELECT (aggregated) | BATID, SCANDT, IDXFL, DELCD |

## Sample SQL

```sql
select
    batid BatchId,
    scandt ScanDate,
    count(*) RemainingDocs
from imgsys
where nvl(idxfl,'N') = 'N'
  and nvl(delcd,' ') = ' '
  and batid = :BatchID
group by batid, scandt
```

## 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`
