---
title: "SQL-029: Count IMAGE_DOCUMENT_TYPE_CODE rows for validation"
summary: Counts matching rows in IMAGE_DOCUMENT_TYPE_CODE to validate that a category/type/file combination exists before saving an image index record.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-029: Count IMAGE_DOCUMENT_TYPE_CODE rows for validation

This statement is a validation query that counts rows in `IMAGE_DOCUMENT_TYPE_CODE` matching a given document type code, category code, and file code combination. It is used by the `clsImageIdx` category/type validation logic (via `clsImageMsgConst.SQL_CAT_TYPE_MISMATCH`) to verify that the combination is valid before saving an image index record.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-029 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text** |
| **Business object** | `clsImageMsgConst` |
| **Criteria property** | `SQL_CAT_TYPE_MISMATCH` |
| **Lifecycle method** | `clsImageIdx category/type validation` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:ImageDocumentTypeCode` | Input | [not specified]** | 5 | The document type code to validate. |
| `:ImageCategoryCode` | Input | [not specified]** | 5 | The category code to validate. |
| `:ImageFileCode` | Input | [not specified]** | 5 | The file code to validate. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMAGE_DOCUMENT_TYPE_CODE](../database-tables.md#image_document_type_code) | SELECT (COUNT) | CODE, IMAGE_CATEGORY_CODE, IMAGE_FILE_CODE |

## Sample SQL

```sql
Select Count(*)
from Image_Document_Type_Code
where Code = :ImageDocumentTypeCode
  and Image_Category_Code = :ImageCategoryCode
  and Image_File_Code = :ImageFileCode
```

## Operations and processes
- [Image indexing](../operations/image-indexing.md)

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

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