SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-19
Checking for Parameters
To check the input parameters:
1. Retrieve the number of input parameters from INPUT-NUM OF SQLSA.
2. Specify a DESCRIBE INPUT statement to access input parameters:
EXEC SQL DESCRIBE INPUT S1
INTO :IN-SQLDA NAMES INTO :IN-NAMESBUF
END-EXEC.
Checking for Output Parameters
To check for output parameters, you perform essentially the same set of operations
described for input parameters except that the pointers point to the output SQLDA and
names buffer and collations buffer. To get the descriptions of the output parameters
into the output SQLDA, use the DESCRIBE statement instead of DESCRIBE INPUT.
To check for variables and allocate space if necessary, perform these steps:
1. Retrieve the number of output parameters from OUTPUT-NUM OF SQLSA.
2. Issue a DESCRIBE statement to access the output parameters. The DESCRIBE
statement can include a COLLATIONS INTO clause, which directs SQL/MP to
return collations to COLL-BUF:
EXEC SQL
DESCRIBE S1
INTO :OUT-SQLDA NAMES INTO :OUT-NAMESBUF
COLLATIONS INTO :COLL-BUF
END-EXEC.
OUTPUT-NAMES-LEN Length of the buffer required to contain the names of the output
parameters.
SQL-STATEMENT-TYPE Type of statement being prepared. Use this information to
decide what type of statement was entered. SQL-
STATEMENT-TYPE can have these values:
1 Cursor SELECT
2 INSERT
3UPDATE
4 DELETE
5 DDL statement
6 Run-time CONTROL TABLE
7 LOCK, UNLOCK, or FREE RESOURCES
8 GET VERSION OF object
OUTPUT-COLLATIONS-
LEN
Length of the output collations buffer if the application uses
collations.
Table 10-4. SQLSA Contents after a Prepare Operation (page2of2)
SQLSA Field Description