Skip to content

Insert preference row

This internal write operation creates a new USER_PREFERENCE row. It binds every column value explicitly, relies on an inline Oracle sequence expression for identity generation, and records audit data from the current portal context.

Field Value
Operation ID OP-PREF-004
Trigger SavePreferences calls InsertPref(appName, pageName, userId, preferenceText) after DoesPrefExist returns false.
Inputs appName, pageName, userId, preferenceText
Outputs true after the insert request is issued
Primary components PreferenceData.InsertPref, SqlHelper.ScalarQuery<int>, SqlHelper.NewParm
Entry point SAIF.Framework.Preferences\PreferenceData.cs

Steps

  1. Use the fixed INSERT statement that targets USER_PREFERENCE and embeds the sequence expression SQL-001 inside the row-creation command SQL-004.
  2. Create a SqlHelper.ScalarQuery<int> bound to the injected IDataPortalInfo, reset the parameter list, and bind the row values (BR-001, BR-003, BR-005, SQL-004, USER_PREFERENCE).
  3. Bind :userid as userId.ToLower().
  4. Bind :appname and :pagename from the caller inputs.
  5. Bind :prefs as preferenceText.Trim().
  6. Bind :updated as System.DateTime.Now.
  7. Bind :updateby as DPI.UserID.
  8. Attach the parameters and execute the scalar request through the active data portal (SQL-001, SQL-004, USER_PREFERENCE).
  9. Create the portal request in the SqlHelper.ScalarQuery<int> constructor.
  10. Add the bind variables to DataRequest through AddParms.
  11. Set DataRequest.RequestType to Scalar and DataRequest.SQLStatement to the INSERT text.
  12. Call IDataPortalInfo.ProcessPortalRequest, then cast DataRequest.Result to int if a scalar result is returned.

Origin: Steps 3.1–3.4 are implemented by Execute a data portal request (SAIF.Framework.Core) and executed on behalf of this operation. 4. Discard the scalar result and return true after the request completes. - On failure: any portal or data-provider exception propagates because this method has no local retry or recovery logic.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([InsertPref called]) --> Build[Build insert parameters]
    Build --> Execute[Execute INSERT with sequence nextval]
    Execute --> EndOk([Return true])

Failure and edge-case behavior

  • pageName is always bound on insert, even though the read/update/delete paths conditionally append page predicates instead of always binding one.
  • The method does not inspect the returned scalar or affected-row count before returning true.
  • Portal or data-provider failures propagate to the caller unmodified.

Sources

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