PrepareSQL()

The PrepareSQL(); rule prepares an SQL statement for execution.

Syntax

The PrepareSQL(); statement uses the following syntax.

PrepareSQL ( sql string, database id, [optional variable list] );

Arguments

The following table lists the properties of the arguments of this stitcher rule.
Table 1. Arguments of PrepareSQL()
Argument Description Accepts constants Accepts variables Accepts eval clauses
sql data The prepared SQL command to execute. The prepared SQL command is presented as an SQLData variable.
Note: SQL queries must not be terminated with a semi-colon.
Yes Yes Yes
database id The database ID, as specified in the DbLogins.cfg file, used to identify the database schema that contains the required table. Yes Yes Yes
optional variable list An optional comma-separated list of variables to be used if placeholders (marked by a question mark symbol, ?) are used in the sql data argument. Yes Yes Yes

Example

The following example shows how the PrepareSQL() rule is used to prepare an SQL statement for execution.

SQLData myData = PrepareSQL(
              "insert into entityNameCache
              (
                            entityName,
                            domainMgrId
              )
              values
              (
                            ?,
                            ?
              );"
              , "NCIM" ,
              eval(text,'$entityName'),
              eval(int,'$domainId')
              );

ExecuteSQL ( myData );