SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
COBOL Sample Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
C-9
Using SQL Descriptor Areas in Dynamic SQL
Using SQL Descriptor Areas in Dynamic SQL
Example C-4 executes the steps shown in Figure 10-2 on page 10-13. 
Example C-4. Using Descriptor Areas With DESCRIBE (page 1 of 4)
*--------------------------------------------------------------
* Description: Using SQL Descriptor Areas
* Statements: ALLOCATE DESCRIPTOR
* PREPARE
* DESCRIBE
* SET DESCRIPTOR
* EXECUTE
* GET DESCRIPTOR
* DEALLOCATE PREPARE
* DEALLOCATE DESCRIPTOR
* WHENEVER
* GET DIAGNOSTICS
*--------------------------------------------------------------
 IDENTIFICATION DIVISION.
 PROGRAM-ID. Program-exF112.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 EXEC SQL BEGIN DECLARE SECTION END-EXEC.
 01 sqlstate pic x(5).
 01 hv-empnum pic 9(4) comp.
 01 hv-first-name pic x(15).
 01 hv-last-name pic x(20).
 01 hv-deptnum pic 9(4) comp.
 01 hv-jobcode pic 9(4) comp.
 01 hv-salary pic 9(6)v9(2) comp.
 01 hv-temp pic 9(6)v9(2) display.
 01 hv-sql-stmt.
 03 in-select pic x(7) value "SELECT ".
 03 in-columns pic x(80).
 03 in-from pic x(80) value " FROM"
 & " samdbcat.persnl.employee"
 & " WHERE empnum = CAST(? AS NUMERIC(4) UNSIGNED)".
 01 hv-prepare-stmt pic x(170).
 01 hv-num pic s9(9) comp.
 01 hv-sqlstate pic x(5).
 01 hv-msgtxt pic x(128).
 01 hv-tabname pic x(128).
 01 hv-colname pic x(128).
 01 sqlda-name pic x(128).
 01 in-empnum pic 9(4) comp.
 01 i pic s9(9) comp.
 01 hv-desc-max pic s9(9) comp.
 01 hv-desc-value pic s9(9) comp.
 EXEC SQL END DECLARE SECTION END-EXEC.
 01 sqlstate-ok pic x(5) value "00000". 










