SQL Programming Manual for Pascal
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal—528614-001
3-28
INVOKE With the PREFIX and SUFFIX Clauses
end;
END;
INVOKE With the PREFIX and SUFFIX Clauses
This example specifies both a prefix and a suffix for indicator variables. The indicator
variables generated are X_ZNUM_2 and X_ZCHAR_2.
The CREATE TABLE statement that defines table TAB is:
CREATE TABLE TAB
( ZNUM NUMERIC (6),
ZCHAR CHARACTER(16),
PRIMARY KEY ZNUM )
CATALOG \SYS.$VOL.TESTCAT ;
The INVOKE directive with the PREFIX and SUFFIX clauses is:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INVOKE TAB PREFIX X_ SUFFIX _2;
EXEC SQL END DECLARE SECTION;
NonStop SQL generates this structure template:
{* Record Definition for table \SYS.$DB.XPERSNL.TAB *}
{* Definition current at 15:32:39 - 09/22/91 *}
type
tab_type = record
x_znum_2 : int16; {indicator variable}
znum : int32;
x_zchar_2 : int16; {indicator variable}
zchar : fstring(16);
end;
OPEN
The OPEN statement opens a cursor.
Static SQL Cursors
A static SQL cursor can only be referred to in procedures in the compilation unit in
which the cursor was declared. This means that for static SQL programs, the
DECLARE CURSOR, OPEN, FETCH, DELETE WHERE CURRENT, UPDATE
WHERE CURRENT, and CLOSE statements that refer to the cursor must be in the
same compilation unit.
If the program exits a procedure with an open cursor, procedures that execute later can
still refer to the cursor as long as the procedures are within the same compilation unit.
Dynamic SQL Cursors
For dynamic SQL cursors, all statements referencing the cursor must be in the
procedure where the cursor is defined; however, if you open the cursor and use it in