SQL/MP Programming Manual for COBOL

Explicit Program Compilation
HP NonStop SQL/MP Programming Manual for COBOL529758-003
6-44
Static SQL Statements
Static SQL Statements
Follow these guidelines when you use CONTROL directives with static SQL
statements:
A CONTROL directive affects subsequent static DML statements in listing order,
regardless of the execution order, until either of these conditions occur:
Another CONTROL directive resets the CONTROL options.
The program encounters the end of the run-time data unit (RTDU) that
contains the CONTROL directive. (An RTDU is a region of the program file that
contains both SQL source statements and object code.)
Each COBOL main program and nested program is a separate RTDU. Therefore, a
CONTROL directive in a main program does not affect statements in a nested
program, and a CONTROL directive in a nested program affects only statements in
the nested program but not in the main program or in other nested programs.
An SQL map shows each RTDU. To generate an SQL map in the compiler listing,
specify the SQLMAP option in the SQL directive.
A dynamic CONTROL directive does not affect static SQL statements in the
program, except as described in the note under Dynamic SQL Statements on
page 6-44.
A CONTROL directive coded within flow-control statements (for example, IF and
ELSE) affects SQL statements in the listing order regardless of the execution
order.
To affect a cursor, you must code the CONTROL directive before the DECLARE
CURSOR statement. The CONTROL directive must also be in the same RTDU as
the DECLARE CURSOR statement.
In this example, the CONTROL EXECUTOR directive specifies parallel evaluation
when the program executes the first FETCH statement for the cursor:
EXEC SQL
CONTROL EXECUTOR PARALLEL EXECUTION ON END-EXEC.
EXEC SQL
DECLARE LIST_CUSTOMERS_WITH_ORDERS CURSOR FOR
SELECT CUSTOMER.CUSTNUM ,
CUSTOMER.CUSTNAME
FROM =CUSTOMER, =ORDERS
WHERE CUSTOMER.CUSTNUM = ORDERS.CUSTNUM
STABLE ACCESS END-EXEC.