SQL Programming Manual for Pascal
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal—528614-001
3-8
CONTROL Directives
A cursor remains open until it is closed. If a static SQL program exits a procedure with
an open cursor, procedures that execute later and that are within the same compilation
unit can still refer to the cursor. If a dynamic SQL cursor is opened and used in one call
to the procedure where it is declared, you can still use the cursor in subsequent calls
without opening the cursor again.
For more information on cursors, see SELECT on page 3-29.
CONTROL Directives
The CONTROL directives are: CONTROL EXECUTOR, CONTROL QUERY, and
CONTROL TABLE.
You can use these directives in either static SQL operations (referred to as static
CONTROL) or in dynamic SQL operations (referred to as dynamic CONTROL). The
scope of a CONTROL directive depends on whether the statements affected are static
SQL statements or dynamic SQL statements.
Static SQL Statements
Static SQL statements follow these rules:
•
A static CONTROL directive affects the execution plan for subsequent static SQL
DML statements in the Pascal source program in listing order (as opposed to
execution order) until another static CONTROL directive resets the option or the
end of the procedure.
•
Static CONTROL directives coded within flow-control statements (such as IF and
ELSE) apply to static SQL DML statements in program listing order, regardless of
whether the CONTROL directive is actually executed.
•
A static CONTROL directive 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.
•
A static CONTROL directive that appears in the global declarations area affects
only cursors declared at the global level.
•
Static SQL statements in the program are not affected by dynamic CONTROL
directives.
Note. One exception to the preceding rules: the TIMEOUT option on a static or dynamic
CONTROL TABLE directive affects all static SQL statements that follow in execution (as
opposed to listing) order, until another static or dynamic CONTROL TABLE directive resets the
option or the end of the program.