SQL Programming Manual for Pascal
Error and Status Processing
HP NonStop SQL Programming Manual for Pascal—528614-001
6-10
Declaring the SQLSA
•
Each SELECT operation through a cursor reports statistics on the OPEN and
CLOSE statements for the cursor, and on each FETCH operation.
Dynamic SQL Statements
•
Each PREPARE statement reports information about input parameters, output
columns, and the input and output names buffer length.
•
Each DESCRIBE INPUT or DESCRIBE statement reports the same information
that was reported by the PREPARE statement (the SQLSA is reinitialized with the
same values for input parameters and output columns).
Other Statements
•
The SQLSA is undefined after DDL, DCL, and transaction control statements.
Declaring the SQLSA
Use the INCLUDE SQLSA directive to declare the SQLSA in your program. You can
declare the SQLSA globally or locally.
The syntax is:
The SQLSA record description is inserted in the program following the INCLUDE
SQLSA directive.
Using the SQLSA
The following guidelines apply when using the SQLSA:
•
Each new statement resets the values in the SQLSA. Therefore, if you are using a
value elsewhere in the program, you might need to save it in a variable
immediately after the statement executes, or declare more than one local SQLSA
structure.
•
Because each FETCH statement resets the SQLSA, to monitor resource use for a
cursor you will need to declare accumulator variables for the statistics you want.
Then add the statistics from the SQLSA fields to the accumulator variables on
each FETCH.
Figure 6-1 on page 6-11 shows the SQLSA data structure generated in a Pascal
program by the INCLUDE SQLSA directive.
EXEC SQL
INCLUDE SQLSA;
Note. Do not put an INCLUDE directive within a TYPE section. INCLUDE directives generate
code with VAR declarations, so that subsequent TYPE declarations would cause errors.