SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-9
CONTROL Directives
Using the CONTROL EXECUTOR Directive
Follow these guidelines when you use the CONTROL EXECUTOR directive:
Execution Plan. The CONTROL EXECUTOR directive affects the execution plan for
subsequent DML statements in the source program in listing order (rather than
execution order) until:
Another CONTROL EXECUTOR directive resets the option.
The end of the procedure occurs.
Scope. The scope of a CONTROL EXECUTOR directive is as follows.
A directive affects SQL statements in the program's listing order, regardless of the
execution order.
If a CONTROL EXECUTOR directive coded with the global declarations, it affects
only global cursors.
If a CONTROL EXECUTOR directive coded in a procedure, it affects only the DML
statements in the procedure.
A CONTROL directive coded in a subprocedure affects all static SQL statements
that follow in listing order until the end of the procedure in which the subprocedure
is embedded.
Flow-Control Statements. A CONTROL EXECUTOR directive coded within flow-
control statements (for example, IF, THEN, and ELSE) applies to static SQL
statements in the program's listing order, regardless of the execution order.
Dynamic SQL Statements. A static CONTROL EXECUTOR directive has no effect on
dynamic SQL statements. To use a CONTROL EXECUTOR directive with dynamic
SQL statements, specify a dynamic CONTROL directive using the PREPARE and
EXECUTE (or EXECUTE IMMEDIATE) statements.
For dynamic SQL cursors, the CONTROL EXECUTOR directive and the DECLARE
CURSOR statement must appear in the same procedure.
In this example, the cursor definition undergoes parallel evaluation as an equijoin
operation when the program issues the first fetch operation on the cursor. The common
column is CUSTNUM. The TACL DEFINEs =CUSTOMER and =ORDERS refer to the
CUSTOMER and ORDERS tables.
EXEC SQL CONTROL EXECUTOR PARALLEL EXECUTION ON ;
EXEC SQL DECLARE list_customers_with_orders CURSOR FOR
SELECT customer.custnum,
customer.custname
FROM =customer, =orders
WHERE customer.custnum = orders.custnum
STABLE ACCESS ;