AppDB ExecuteSQL() Method

(SBM On-Premise/PaaS only) Executes SQL in the database. See important notes below.

Function Signature

 void ExecuteSQL( sqlText [, Vector params] )

Parameters

Parameter Type Description

sqlText

string

The SQL to pass in.

params

Vector

An optional Vector storing SQL bind parameters, where each entry is a Pair, with the first value as the parameter type and the second value as the value to bind to the SQL parameter. Corresponds to DBTypeConstants. See Pair, Map_Pair, and Dictionary_Pair.

Return

Type Description

None

Technical Details

SBM ModScript version: 11.4.1.

Example

Shell.Db().ExecuteSQL(
  "with uvh as ( select TS_ID from TS_USER_VIEWHISTORY with(nolock) 
     where TS_USERID = ? and TS_TABLEID = ? and TS_ITEMID = ? )
   update u set u.TS_TIMESTAMP=GETUTCDATE() 
     from TS_USER_VIEWHISTORY u join uvh on u.TS_ID=uvh.TS_ID", 
  [ Pair( DBTypeConstants.INTEGER, 8 ),
    Pair( DBTypeConstants.INTEGER, 1006 ),
    Pair( DBTypeConstants.INTEGER, 2 ) ] )

Notes

Use caution when changing the database directly:

  • No change history is written by SBM based on changes you make to the database.
  • For data that is cached by SBM components, changes made directly to the database will not invalidate the cache.
  • Certain things are stored in multiple places. For example, Multi-Relational field values are stored as comma-separated values in primary/auxiliary tables, but also are maintained in the TS_USAGES table so that values are searched using an indexed query. Changing a value without ensuring that all related locations are updated can lead to undefined behavior.

Related Topics

AppDb