SQL Descriptor Area (SQLDA) in COBOL
The SQLDA provides the programmer with comprehensive information about each resulting column of a dynamic SELECT statement.
The following is the declaration of the SQLDA structure in COBOL:
01 SQLDA.
02 SQLDAID PIC X(8) VALUE "SQLDA".
02 SQLDABC PIC S9(9) COMP SYNC VALUE 0.
02 SQLN PIC S9(4) COMP SYNC VALUE 0.
02 SQLD PIC S9(4) COMP SYNC VALUE 0.
02 SQLVAR.
03 SQLTYPE PIC S9(9) COMP SYNC VALUE 0.
03 SQLLEN PIC S9(9) COMP SYNC VALUE 0.
03 RESERVED PIC S9(9) COMP SYNC VALUE 0.
03 INTERNAL PIC S9(4) COMP SYNC VALUE 0.
03 SQLINDLEN PIC S9(4) COMP SYNC VALUE 0.
03 SQLINDTYPE PIC S9(9) COMP SYNC VALUE 0.
03 SQLIND.
04 PTR PIC S9(9) COMP SYNC VALUE 0.
04 HAD PIC S9(9) COMP SYNC VALUE 0.
03 SQLDATA.
04 PTR PIC S9(9) COMP SYNC VALUE 0.
04 HAD PIC S9(9) COMP SYNC VALUE 0.
03 SQLNAME.
04 SQLNAMEL PIC S9(9) COMP SYNC VALUE 0.
04 SQLNAMET PIC S9(9) COMP SYNC VALUE 0.
04 SQLNAMER PIC S9(9) COMP SYNC VALUE 0.
You must call the folloiwng subroutine to set the address of a host variable in SQLDATA and, optionally, in SQLIND.
CALL "SAGADDR" USING <host variable name> sqldata of sqlvar of outsqlda(<index>)
Example:
CALL "SAGADDR" USING C2 sqldata of sqlvar of outsqlda(1)