SQLExec
Mon 01 January 2018Syntax
SQLExec({sqlcmd | SQL.sqlname}, [bindexprs [, outputvars]])
where bindexprs is a list of expressions, one for each :n reference within sqlcmd or the text found in the SQL defintion sqlname, in the form:
inexpr_1 [, inexpr_2]. . .
and where outputvars is a list of variables, record fields, or record object references, one for each column selected by the SQL command, in the form:
out_1 [, out_2]. . .
Description
Use the SQLExec function to execute a SQL command from within a PeopleCode program by passing a SQL command string. The SQL command bypasses the Component Processor and interacts with the database server directly. If you want to delete, insert, or update a single record, use the corresponding PeopleCode record object method.
If you want to delete, insert, or update a series of records, all of the same type, use the CreateSQL or GetSQL functions, then the Execute SQL class method.
Note: SQLExec opens a new database cursor each time it executes.
Parameters
Field or Control |
Definition |
---|---|
sqlcmd | SQL . sqlname |
Specify either a String containing the SQL command to be executed or a reference to an existing SQL definition. This string can include bind variables, inline bind variables, and meta-SQL. |
bindexprs |
A list of expressions, each of which corresponds to a numeric (: n ) bind variable reference in the SQL command string. It can also be a reference to a record object or an array of Any containing all the bind values. See Bind Variables in SQLEXEC for more details. |
outputvars |
A list of PeopleCode variables or record fields to hold the results of a SQL SELECT. There must be one variable for each column specified in the SELECT statement. It can also be a reference to a record object or an Array of Any that contains all the selected values. |
Returns
Optionally returns a Boolean value indicating whether the function executed successfully.
Note: Not returning a row is not considered an error. If this is a concern, consider using the %SqlRows system variable after your call to SQLExec.