SQL Programming Manual for TAL
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL—527887-001
3-8
CONTROL Directives
This example shows the CLOSE statement in a typical sequence of statements that
use a cursor.
EXEC SQL
DECLARE check_emp CURSOR FOR ! Declare the cursor.
SELECT deptnum
FROM employee
WHERE deptnum = :deptnum^del
FOR UPDATE OF deptnum ;
...
! get a value for :deptnum^del.
EXEC SQL
OPEN check_emp ; ! Open the cursor.
! FETCH rows until the NOT FOUND condition is met.
WHILE SQLCODE >= 100 DO
BEGIN
EXEC SQL
FETCH check_emp ! FETCH a value.
INTO :deptnum ;
! Delete a row that matches the criteria.
...
END
EXEC SQL
CLOSE check_emp ; ! Close the cursor.
CONTROL Directives
The CONTROL directives and their functions are:
CONTROL EXECUTOR
Allows or prohibits parallel evaluation of a query by multiple SQL executors
CONTROL QUERY
Specifies whether NonStop SQL should optimize the query time for either returning
the first few rows found or for returning all the rows found
CONTROL TABLE
Specifies options that control locks and opens on tables and views, and whether to
buffer INSERT and UPDATE operations
You can use CONTROL directives with either static SQL or dynamic SQL statements.
CONTROL directives do not affect SQL DDL statements. The SQL/MP Reference
Manual contains general information and syntax for the CONTROL directives. The
following paragraphs provide information for using the directives in a TAL program.