---
title: "SQL-006: Delete preference row"
summary: Deletes a USER_PREFERENCE row for an application/page/user combination.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Preferences
reference_type: package
---

# SQL-006: Delete preference row

This DELETE removes a preference row for a given application/user combination, optionally scoped to a specific page name. It backs `PreferenceData.DeletePref`, invoked from `SavePreferences` when the supplied preference text is empty or whitespace-only.

## Classification

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

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:userid` | Input | string (`SqlHelper.NewParm`) | 40 | Lower-cased user ID; row-selection predicate for delete. |
| `:appname` | Input | string (`SqlHelper.NewParm`) | 40 | Application name; row-selection predicate for delete. |
| `:pagename` | Input | string (`SqlHelper.NewParm`) | 40 | Optional page name; only bound when `pageName` is non-empty. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [USER_PREFERENCE](../database-tables.md#user_preference) | DELETE | `USER_ID`, `APP_NAME`, `PAGE_NAME` |

## Sample SQL

```sql
-- Default form (no page name supplied)
Delete from USER_PREFERENCE
where USER_ID = :userid
  and APP_NAME = :appname
  and PAGE_NAME is NULL
```

```sql
-- When pageName is supplied, the final predicate is replaced with:
Delete from USER_PREFERENCE
where USER_ID = :userid
  and APP_NAME = :appname
  and PAGE_NAME = :pagename
```

## Operations and processes
- [Delete preference row](../operations-processes.md#delete-preference-row)
- [Save (upsert/delete) preference](../operations-processes.md#save-upsertdelete-preference)

## Business rules
- [BR-001: User IDs are normalized to lower case](../business-rules.md#br-001-user-ids-are-normalized-to-lower-case)
- [BR-002: Empty preference text triggers deletion](../business-rules.md#br-002-empty-preference-text-triggers-deletion)
- [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
