Skip to content

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

  1. Start with the base DELETE statement for USER_PREFERENCE filtered by USER_ID and APP_NAME (SQL-006, USER_PREFERENCE).
  2. Create a SqlHelper.ScalarQuery<int>, reset the parameter list, and bind :userid as userId.ToLower() plus :appname as the application name (BR-001, SQL-006, USER_PREFERENCE).
  3. Apply optional page scoping before execution (BR-003, SQL-006, USER_PREFERENCE).
  4. If pageName is empty, append and PAGE_NAME is NULL.
  5. If pageName is present, append and PAGE_NAME = :pagename and bind the page parameter.
  6. Attach the parameters and execute the delete request through the active portal (SQL-006, USER_PREFERENCE).
  7. Create the portal request in the SqlHelper.ScalarQuery<int> constructor.
  8. Add the bind variables to DataRequest through AddParms.
  9. Set DataRequest.RequestType to Scalar and DataRequest.SQLStatement to the DELETE text.
  10. Call IDataPortalInfo.ProcessPortalRequest, then cast DataRequest.Result to int if 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. Return true without 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 pageName scopes the delete to rows whose PAGE_NAME is NULL.
  • A request that matches zero rows still returns true, so callers cannot distinguish "deleted" from "nothing to delete".
  • The preferenceText parameter is accepted but unused; it has no effect on delete behavior.

Sources

  • SAIF.Framework.Preferences\PreferenceData.cs
  • SAIF.Framework.Core\V1\DataAccessLayer\SqlHelper.vb