---
title: "SQL-001: Insert preference — sequence key generation"
summary: Inline sequence-generation expression used to produce the primary key for new USER_PREFERENCE rows.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Preferences
reference_type: package
---

# SQL-001: Insert preference — sequence key generation

This is the inline `USER_PREFERENCE_SEQ.nextval` expression embedded directly in the `VALUES` clause of the SQL-004 INSERT statement inside `InsertPref`. There is no separate `SELECT ... NEXTVAL FROM DUAL` round trip — the sequence value is generated as part of the single INSERT execution.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-001 |
| **Operation type** | Create (Sequence) |
| **Execution method** | Inline SQL (embedded expression within `SqlHelper.ScalarQuery<int>.Execute`) |
| **Database** | Oracle |
| **Schema** | `[unqualified]**` |
| **Command type** | Text |
| **Business object** | `PreferenceData` |
| **Criteria property** | n/a (no `IBusinessCriteria`) |
| **Lifecycle method** | `InsertPref` |

## Parameters

No bind parameters. The next primary-key value is generated via the inline `USER_PREFERENCE_SEQ.nextval` expression embedded in the SQL-004 INSERT's `VALUES` clause.

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [USER_PREFERENCE](../database-tables.md#user_preference) | INSERT (key source only; no FROM clause) | `USER_PREFERENCE_SEQ_NUM` |

## Sample SQL

```sql
-- Inline sequence expression embedded in the SQL-004 INSERT statement's VALUES clause
-- (PreferenceData.InsertPref) — not a separate round-trip query:
USER_PREFERENCE_SEQ.nextval
```

## Operations and processes
- [Insert preference row](../operations-processes.md#insert-preference-row)

## Business rules
- [BR-003: Preference identity is scoped by app, user, and optional page](../business-rules.md#br-003-preference-identity-is-scoped-by-app-user-and-optional-page)

## Sources
- SAIF.Framework.Preferences\PreferenceData.cs
