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

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-35
COBOL Examples of DESCRIBE
...
EXEC SQL PREPARE S1 FROM :stmt_buffer;
...
desc_max = 1;
EXEC SQL ALLOCATE DESCRIPTOR 'in_args' WITH MAX :desc_max;
desc_max = 6;
EXEC SQL ALLOCATE DESCRIPTOR 'out_cols' WITH MAX :desc_max;
...
EXEC SQL DESCRIBE INPUT S1 USING SQL DESCRIPTOR 'in_args';
EXEC SQL DESCRIBE OUTPUT S1 USING SQL DESCRIPTOR 'out_cols';
...
COBOL Examples of DESCRIBE
Return descriptions of input parameters for the prepared statement identified by
:stmt-name to the SQL descriptor area identified by the host variable
:input_sqlda:
EXEC SQL DESCRIBE INPUT :stmt-name
USING SQL DESCRIPTOR :input_sqlda
END-EXEC.
Return descriptions of output variables specified in the prepared statement
identified by S1 to the SQL descriptor area identified by the character literal
'output_sqlda':
EXEC SQL DESCRIBE OUTPUT S1
USING SQL DESCRIPTOR 'output_sqlda'
END-EXEC.
Prepare a statement and allocate and describe the input and output descriptor
areas:
...
MOVE "SELECT * FROM EMPLOYEE"
& " WHERE EMPNUM = CAST(? AS NUMERIC(4) UNSIGNED)"
TO stmt-buffer.
...
EXEC SQL PREPARE S1 FROM :stmt-buffer END-EXEC.
...
MOVE 1 TO desc-max.
EXEC SQL ALLOCATE DESCRIPTOR 'in_args'
WITH MAX :desc-max END-EXEC.
MOVE 6 TO desc-max.
EXEC SQL ALLOCATE DESCRIPTOR 'out_cols'
WITH MAX :desc-max END-EXEC.
...
EXEC SQL DESCRIBE INPUT S1
USING SQL DESCRIPTOR 'in_args'
END-EXEC.
EXEC SQL DESCRIBE OUTPUT S1
USING SQL DESCRIPTOR 'out_cols'
END-EXEC.
...