---
title: "SQL-004: Insert IMAGE_AFFILIATION row"
summary: Inserts a new row into IMAGE_AFFILIATION to associate an image with an affiliated business entity.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-004: Insert IMAGE_AFFILIATION row

This statement inserts a new row into the `IMAGE_AFFILIATION` table, recording the association between an image (by `IMAGE_SEQ_NUM`) and an affiliated entity (by `AFFILIATION_IMAGE_SEQ_NUM`). The `CREATE_DATE` is set using Oracle `sysdate`.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:AffiliationImageSeqNum` | Input | [not specified]** | N/A | The affiliation image sequence number. |
| `:CreateUser` | Input | [not specified]** | 30 | User ID of the record creator. |
| `:ImageAffiliationSeqNum` | Input | [not specified]** | N/A | Primary key for the IMAGE_AFFILIATION row (from SQL-001). |
| `:ImageSeqNum` | Input | [not specified]** | N/A | Foreign key to the IMAGE row. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMAGE_AFFILIATION](../database-tables.md#image_affiliation) | INSERT | AFFILIATION_IMAGE_SEQ_NUM, CREATE_DATE, CREATE_USER, IMAGE_AFFILIATION_SEQ_NUM, IMAGE_SEQ_NUM |

## Sample SQL

```sql
Insert into IMAGE_AFFILIATION (
    AFFILIATION_IMAGE_SEQ_NUM,
    CREATE_DATE,
    CREATE_USER,
    IMAGE_AFFILIATION_SEQ_NUM,
    IMAGE_SEQ_NUM
) Values (
    :AffiliationImageSeqNum,
    sysdate,
    :CreateUser,
    :ImageAffiliationSeqNum,
    :ImageSeqNum
)
```

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

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

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