SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-52
Considerations for GET DESCRIPTOR
Considerations for GET DESCRIPTOR
Processing Items in a Descriptor Area
You can retrieve:
The number of filled-in descriptor items
Fields for a specific item
You can use the number of filled-in descriptor items to construct a loop to process
individual items.
Version Differences for TYPE and TYPE_FS
In NonStop SQL/MX Release 1.0, the FS type (an SQL/MX extension) was equivalent
to the item TYPE, and the ANSI type was equivalent to the item TYPE_ANSI. In
NonStop SQL/MX Release 1.5 and later, to comply with ANSI standards, these
equivalents have changed. TYPE returns the ANSI type, and TYPE_FS returns the FS
type (an SQL/MX extension).
C Examples of GET DESCRIPTOR
Allocate a descriptor area, describe the output parameters of a dynamic SQL
statement, and use the descriptor area to get information about the parameters:
...
desc_max = 10;
EXEC SQL ALLOCATE DESCRIPTOR 'out_sqlda' WITH MAX :desc_max;
...
EXEC SQL DESCRIBE OUTPUT dynamic_stmt
USING SQL DESCRIPTOR 'out_sqlda';
...
/* First, get the count of the number of output values. */
EXEC SQL GET DESCRIPTOR 'out_sqlda' :num = COUNT;
/* Second, get the i-th output values and save. */
for (i = 1; i <= num; i++) {
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:sqlda_type = TYPE,
:sqlda_length = LENGTH,
:sqlda_name = NAME;
/* Test type or name to determine the host variable, */
/* assign data value to appropriate host variable. */
...
if (strncmp(sqlda_name,"LAST_NAME",strlen("LAST_NAME"))==0)
EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i
:hv_last_name = VARIABLE_DATA;
...
}
... /* process the item descriptor values */
EXEC SQL DEALLOCATE DESCRIPTOR 'out_sqlda';