SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Dynamic SQL With Descriptor Areas
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
10-7
Output Variables
For multiple input parameters, set the individual descriptors in the order of their
occurrence in the dynamic SQL statement. For a complete example of this method,
see Example A-5 on page A-12.
Output Variables
NonStop SQL/MX returns data to a program through output variables. Output variables
can be host variables or individual data buffers to which the program (through the SQL
descriptor area) contains pointers. Output variables typically contain columns returned
from a SELECT or FETCH operation. A program uses the DESCRIBE statement to set
information on the output variables in the output descriptor area.
Describing Output Variables
Use a DESCRIBE OUTPUT statement to set output values for a prepared SELECT
statement. Use GET DESCRIPTOR to retrieve the values.
Use this general syntax:
For complete syntax, see the DESCRIBE statement in the SQL/MX Reference Manual.
When DESCRIBE OUTPUT executes, NonStop SQL/MX stores the value of each
output variable of the prepared statement in an item descriptor area. Each output value
has a separate descriptor area.
Getting the Values of Output Variables
Use the GET DESCRIPTOR statement to retrieve the number (count) of item
descriptor areas and to retrieve the value of an output variable in a specific item
descriptor area.
Use this general syntax:
For complete syntax, see the GET DESCRIPTOR statement in the SQL/MX Reference
Manual.
The DESCRIBE OUTPUT statement sets fields in the SQL item descriptor area for
every column in the select list of a dynamic SELECT statement or in the select list of a
cursor specification for a dynamic SQL cursor. COUNT is set equal to the number of
columns. The NAME field contains the name of each column. The TYPE field contains
the data type of each column.
DESCRIBE [OUTPUT] statement-name
USING SQL DESCRIPTOR descriptor-name
GET DESCRIPTOR descriptor-name
{ variable-name = COUNT }
{ VALUE item-number variable-name = desc-item-name,... }