SQL/MX 2.x Reference Manual (G06.24+, H06.03+)
Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual—523725-004
3-55
COBOL Examples of GET DESCRIPTOR
COBOL 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:
 MOVE 10 TO desc-max.
 EXEC SQL ALLOCATE DESCRIPTOR 'out_sqlda' 
 WITH MAX :desc-max END-EXEC.
 ...
 EXEC SQL DESCRIBE OUTPUT dynamic_stmt
 USING SQL DESCRIPTOR 'out_sqlda' END-EXEC.
 ...
* First, get the count of the number of output values.
 EXEC SQL
 GET DESCRIPTOR 'out_sqlda' :num = COUNT
 END-EXEC.
* Second, get the i-th output values and save.
 PERFORM VARYING i FROM 1 BY 1 UNTIL i > num
 EXEC SQL GET DESCRIPTOR 'out_sqlda' VALUE :i 
 :sqlda-type = TYPE,
 :sqlda-length = LENGTH,
 :sqlda-name = NAME 
 END-EXEC.
* Test type or name to determine the host variable, 
* assign data value to the appropriate host variable. 
 ...
 IF sqlda-name = "LAST_NAME"
 EXEC SQL
 GET DESCRIPTOR 'out_sqlda' VALUE :i
 :hv-last-name = VARIABLE_DATA
 END-EXEC.
 ...
 END-PERFORM.
 ...
* Process the item descriptor values 
 ...
 EXEC SQL DEALLOCATE DESCRIPTOR 'out_sqlda' END-EXEC.










