NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
E-10
Examples—EXECUTE
You can specify parameter values for named formal parameters with the USING
clause, with the SQLCI SET PARAM command, or with the TACL PARAM
command. (A TACL PARAM named “A” is the same as a parameter named “?A” in
SQLCI.) You can specify parameter values for unnamed parameters only with the
USING clause.
Name resolution in executed statements
Unless a CONTROL QUERY BIND NAMES AT EXECUTION directive is in
effect when a PREPARE executes, the compiled statement uses the defaults and
DEFINEs in effect at the time it is prepared, not the time it executes. (See
CONTROL QUERY Directive
on page C-70 or Name Resolution on page N-2 for
details.)
TMF considerations for nonaudited tables or indexes
You cannot execute a prepared DDL statement (except UPDATE STATISTICS) that
operates on nonaudited tables or indexes within a user-defined TMF transaction.
Examples—EXECUTE
The following program fragment uses PREPARE and EXECUTE to compile the
statement stored in the variable :DYNSTMT and execute it using parameter values
stored in the variables :PARTNUM, :PRICE, and :PARTDESC:
EXEC SQL
PREPARE OPERATION FROM :DYNSTMT;
EXEC SQL
EXECUTE OPERATION USING :PARTNUM, :PRICE, :PARTDESC;
The following SQLCI example uses PREPARE to compile a statement once, then
executes the statement multiple times with different parameter values:
PREPARE FINDEMP FROM "SELECT * FROM PERSNL.EMPLOYEE"
&"WHERE SALARY > ? AND JOBCODE = ? ";
EXECUTE FINDEMP USING 30000, 200;
EXECUTE FINDEMP USING 40000, 100;
The following SQLCI statements use CURRENT_TIMESTAMP and
COMPUTE_TIMESTAMP in EXECUTE USING clauses as values for both
LARGEINT and TIMESTAMP fields. Notice how the prepared statement uses