---
title: SAIF.Framework.CodeGen operations and processes
summary: Business and technical operations supported by this library.
status: draft
owner: SAIF DocGen
last_reviewed: 2026-07-30
library: SAIF.Framework.CodeGen
reference_type: package
---

# SAIF.Framework.CodeGen operations and processes

`SAIF.Framework.CodeGen` exposes exactly three operations, all owned by the single public class `CodeTableMap`. One operation prepares the Oracle connection the other two depend on; the remaining two read the same reference-data query and transform its rows into different flavors of VB.NET source text. This page is the operation catalog and cross-operation hub for the library — each operation's detailed, step-by-step logic lives in its own page under `operations/`.

## Operation catalog
| Operation | Intent | Trigger | Inputs | Outputs | Rules | Tables | SQL |
| --- | --- | --- | --- | --- | --- | --- | --- |
| [Establish/refresh Oracle data connection](operations/establish-refresh-oracle-data-connection.md)<span id="establishrefresh-oracle-data-connection"></span> | Prepare or reuse the Oracle data-portal handle that the two generation operations execute their query through | Constructor call, or a later explicit `Connect` invocation | `dbUser`, `database` | Populated or reused `m_dpi As IDataPortalInfo` | [BR-004](business-rules.md#br-004-data-connection-is-only-re-established-when-parameters-change) | — | — |
| [Generate VB Case statement block](operations/generate-vb-case-statement-block.md)<span id="generate-vb-case-statement-block"></span> | Turn a code table's rows into a `Case` / `Me.Add(...)` block a developer can paste into hand-written VB source | Caller invokes `CreateCaseStatement(...)` | `table`, `enumName`, `rowItem`, `useDescriptionAsCode`, `tabIndex` | Generated VB source text | [BR-001](business-rules.md#br-001-enum-member-identifiers-must-be-unique-within-a-generated-block), [BR-002](business-rules.md#br-002-generated-enum-member-identifiers-must-be-legal-vb-identifiers), [BR-003](business-rules.md#br-003-enum-member-identifier-derivation-strips-non-alphabetic-characters-from-the-description) | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) | [SQL-001](sql/SQL-001-select-code-table.md) |
| [Generate VB Enum member list](operations/generate-vb-enum-member-list.md)<span id="generate-vb-enum-member-list"></span> | Turn a code table's rows into a VB `Enum` member list a developer can paste into hand-written VB source | Caller invokes `CreateEnumStatement(...)` | `table`, `enumName`, `includeNull`, `useDescriptionAsCode`, `tabIndex` | Generated VB source text | [BR-001](business-rules.md#br-001-enum-member-identifiers-must-be-unique-within-a-generated-block), [BR-002](business-rules.md#br-002-generated-enum-member-identifiers-must-be-legal-vb-identifiers), [BR-003](business-rules.md#br-003-enum-member-identifier-derivation-strips-non-alphabetic-characters-from-the-description) | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) | [SQL-001](sql/SQL-001-select-code-table.md) |

## Process flow diagram
The following diagram traces a caller's typical path through the library: construct `CodeTableMap` (which connects), then request either a `Case` block or an `Enum` list from the same code-table query.

```mermaid
flowchart TD
	Start([Caller constructs CodeTableMap]) --> Connect[Establish or reuse Oracle data connection]
	Connect --> Choice{Requested output?}
	Choice -->|Case block| QueryCase[Read code-table rows]
	Choice -->|Enum list| QueryEnum[Read code-table rows]
	QueryCase --> CaseLoop[Derive unique VB identifiers<br>and emit Case / Me.Add lines]
	QueryEnum --> EnumNull{includeNull?}
	EnumNull -->|Yes| AddNull[Emit leading Null member]
	EnumNull -->|No| EnumLoop[Derive unique VB identifiers<br>and emit enum-member lines]
	AddNull --> EnumLoop
	CaseLoop --> EndCase([Return Case block text])
	EnumLoop --> EndEnum([Return enum-member text])
```

## Inherited operations and processes

The query-execution steps embedded in the two generation operations originate in base classes and services provided by `SAIF.Framework.Core`. They are inherited or delegated, not implemented in this library. (The Oracle connection operation delegates separately to `SAIF.Framework.Core`'s data-portal request pipeline; see the `> Origin` callout on its own page.)

### From `SqlHelper.ResultSetQuery` / `IDataPortalInfo` (`SAIF.Framework.Core`)

| Operation | Intent | Provided by | Origin | Embedded in |
| --- | --- | --- | --- | --- |
| [Framework data-portal request flow](../saif-framework-core/architecture.md#interaction-model) | Route the code-table `SELECT` through the configured Oracle data portal and return the resulting `clsResultSet` | `SqlHelper.ResultSetQuery`, `IDataPortalInfo` | `SAIF.Framework.Core` | [Generate VB Case statement block](operations/generate-vb-case-statement-block.md), [Generate VB Enum member list](operations/generate-vb-enum-member-list.md) |

> **Origin**: This framework operation is defined in `SAIF.Framework.Core` and its step-by-step logic is embedded inline, with `> Origin` callouts, in the consuming operation pages listed above.

## Database interactions

Both generation operations read the same code table through the same query; neither writes to the database. Per-step SQL and table citations live in each operation's detail page under `operations/`.

| Operation | SQL | Tables | Type |
| --- | --- | --- | --- |
| [Generate VB Case statement block](operations/generate-vb-case-statement-block.md) | [SQL-001](sql/SQL-001-select-code-table.md) | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) | Read |
| [Generate VB Enum member list](operations/generate-vb-enum-member-list.md) | [SQL-001](sql/SQL-001-select-code-table.md) | [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) | Read |

## Failure and edge-case behavior
- Repeated identifiers are disambiguated by appending the row's raw `code` value before the line is emitted, so no generated block ever contains two members with the same name ([BR-001](business-rules.md#br-001-enum-member-identifiers-must-be-unique-within-a-generated-block)).
- Description-derived identifiers strip every non-alphabetic character and are prefixed with `Code` when the stripped result is purely numeric, keeping every generated member name syntactically legal VB ([BR-003](business-rules.md#br-003-enum-member-identifier-derivation-strips-non-alphabetic-characters-from-the-description), [BR-002](business-rules.md#br-002-generated-enum-member-identifiers-must-be-legal-vb-identifiers)).
- A repeated `Connect` call with the same `dbUser` and `database` reuses the existing data portal instead of rebuilding it ([BR-004](business-rules.md#br-004-data-connection-is-only-re-established-when-parameters-change)).
- The shared lookup query is unfiltered and unparameterized: it always reads every `code`/`code_descr` row exposed by [SQL-001](sql/SQL-001-select-code-table.md) from [CODE_TABLE (caller-supplied)](database-tables.md#code_table-caller-supplied) — the only caller-controlled input is the table name itself.
- An empty result set produces empty generated text for `CreateCaseStatement`, or text containing only the optional `Null` member for `CreateEnumStatement`. Connection failures and query failures are not caught locally, so both propagate directly to the caller.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Architecture](architecture.md)
- [Dependencies](dependencies.md)
- [Business rules](business-rules.md)
- [Configuration](configuration.md)
- [Database tables](database-tables.md)
- [SQL catalog](sql/index.md)
- [API reference](api/index.md)

## Sources
- SAIF.Framework.CodeGen\CodeTableMap.vb
- SAIF.Framework.Core\V1\DataAccessLayer\SqlHelper.vb
- SAIF.Framework.Core\V1\DataAccessLayer\MSOracle\MSOracleDataLayer.vb
- SAIF.Framework.Core\V1\Interfaces\iDataPortalInfo.vb
