Skip to content

SQL-007: Check preference existence

This scalar Count(*) check determines whether a matching USER_PREFERENCE row already exists for the given application/user (and optional page name). It backs PreferenceData.DoesPrefExist, called from SavePreferences to decide whether to dispatch to UpdatePref or InsertPref.

Classification

Field Value
SQL ID SQL-007
Operation type Read
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 DoesPrefExist

Parameters

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

Tables

Table Access Columns used
USER_PREFERENCE SELECT USER_ID, APP_NAME, PAGE_NAME

Sample SQL

-- Default form (no page name supplied)
select Count(*)
from USER_PREFERENCE
where USER_ID = :userid
  and APP_NAME = :appname
  and PAGE_NAME is NULL
-- When pageName is supplied, the final predicate is replaced with:
select Count(*)
from USER_PREFERENCE
where USER_ID = :userid
  and APP_NAME = :appname
  and PAGE_NAME = :pagename

Operations and processes

Business rules

Sources

  • SAIF.Framework.Preferences\PreferenceData.cs