---
title: "SQL-001: Select code table reference rows"
summary: Ad hoc SELECT that retrieves code/description reference rows for VB source-code generation.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.CodeGen
reference_type: package
---

# SQL-001: Select code table reference rows

This is the sole SQL statement in `SAIF.Framework.CodeGen`. It is a read-only lookup against a caller-supplied "code table," used to source `code`/`code_descr` reference rows that `CodeTableMap` transforms into generated VB `Case` statement blocks or `Enum` member lists.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-001 |
| **Operation type** | Read |
| **Execution method** | Inline (String.Format-assembled text, executed via `SqlHelper.ResultSetQuery.Execute`) |
| **Database** | Oracle |
| **Schema** | `[unqualified]**` — no explicit `OWNER.TABLE_NAME` qualifier appears in the SQL text |
| **Command type** | Text |
| **Business object** | N/A (Application/tooling layer) |
| **Application class** | `CodeTableMap` |
| **Criteria property** | N/A |
| **Lifecycle method** | N/A — invoked from the private `GetResult(table As String)` helper, called by both `CreateCaseStatement` and `CreateEnumStatement` |

## Parameters

No `AddParm()` / `AddCursorParm()` / bind-variable (`:Name`) parameters are used. The only variable input is the table name itself, which is spliced directly into the SQL text via `String.Format("select code, code_descr from {0}", table)` rather than passed as a bound parameter. This is a direct string-substitution pattern, not a parameterized query.

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [CODE_TABLE (caller-supplied)](../database-tables.md#code_table-caller-supplied) | SELECT | `code`, `code_descr` |

## Sample SQL

```sql
-- Literal format string found in source: String.Format("select code, code_descr from {0}", table)
-- The {table} placeholder is substituted at runtime with a table name supplied by the
-- caller of CreateCaseStatement or CreateEnumStatement; it is never a fixed literal.
select code, code_descr from {table}
```

Execution: `Dim query As New SqlHelper.ResultSetQuery(m_dpi)` then `query.Execute(sql)`, returning a `clsResultSet`. There is no `WHERE` clause, no bind variables, and no `ORDER BY` — only the two selected columns `code` and `code_descr`. The Oracle database target is confirmed via the `clsMSOracleDataLayer` construction in `Connect` (`m_dpi = New clsMSOracleDataLayer(dbUser, database).DataPortalInfo`), not via SQL syntax markers.

## Operations and processes
- [Generate VB Case statement block](../operations-processes.md#generate-vb-case-statement-block)
- [Generate VB Enum member list](../operations-processes.md#generate-vb-enum-member-list)

## Business rules
- [BR-001: Enum member identifiers must be unique within a generated block](../business-rules.md#br-001-enum-member-identifiers-must-be-unique-within-a-generated-block)
- [BR-002: Generated enum-member identifiers must be legal VB identifiers](../business-rules.md#br-002-generated-enum-member-identifiers-must-be-legal-vb-identifiers)
- [BR-003: Enum-member identifier derivation strips non-alphabetic characters from the description](../business-rules.md#br-003-enum-member-identifier-derivation-strips-non-alphabetic-characters-from-the-description)

## Sources
- SAIF.Framework.CodeGen\CodeTableMap.vb
