Delete preference row¶
This internal write operation removes the preference row that matches the requested application/user scope, applying the same optional page-name scoping used by the read and existence-check paths.
| Field | Value |
|---|---|
| Operation ID | OP-PREF-006 |
| Trigger | SavePreferences calls DeletePref(appName, pageName, userId, preferenceText) when the trimmed preference text is empty. |
| Inputs | appName, pageName, userId, preferenceText |
| Outputs | true after the delete request is issued |
| Primary components | PreferenceData.DeletePref, SqlHelper.ScalarQuery<int> |
| Entry point | SAIF.Framework.Preferences\PreferenceData.cs |
Steps¶
- Start with the base DELETE statement for USER_PREFERENCE filtered by
USER_IDandAPP_NAME(SQL-006, USER_PREFERENCE). - Create a
SqlHelper.ScalarQuery<int>, reset the parameter list, and bind:useridasuserId.ToLower()plus:appnameas the application name (BR-001, SQL-006, USER_PREFERENCE). - Apply optional page scoping before execution (BR-003, SQL-006, USER_PREFERENCE).
- If
pageNameis empty, appendand PAGE_NAME is NULL. - If
pageNameis present, appendand PAGE_NAME = :pagenameand bind the page parameter. - Attach the parameters and execute the delete request through the active portal (SQL-006, USER_PREFERENCE).
- Create the portal request in the
SqlHelper.ScalarQuery<int>constructor. - Add the bind variables to
DataRequestthroughAddParms. - Set
DataRequest.RequestTypetoScalarandDataRequest.SQLStatementto the DELETE text. - Call
IDataPortalInfo.ProcessPortalRequest, then castDataRequest.Resulttointif a scalar result is returned.
Origin: Steps 4.1–4.4 are implemented by Execute a data portal request (
SAIF.Framework.Core) and executed on behalf of this operation. 5. Returntruewithout checking how many rows were actually removed. - On failure: any portal or provider exception propagates to the caller.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([DeletePref called]) --> Scope[Apply page-specific delete scope]
Scope --> Execute[Execute DELETE]
Execute --> EndOk([Return true])
Failure and edge-case behavior¶
- Empty
pageNamescopes the delete to rows whosePAGE_NAMEisNULL. - A request that matches zero rows still returns
true, so callers cannot distinguish "deleted" from "nothing to delete". - The
preferenceTextparameter is accepted but unused; it has no effect on delete behavior.
Related documentation¶
Sources¶
- SAIF.Framework.Preferences\PreferenceData.cs
- SAIF.Framework.Core\V1\DataAccessLayer\SqlHelper.vb