The following statements require an SQLDA:
Unlike the SQLCA, there can be more than one SQLDA in a program, and an SQLDA can have any valid name. An SQLDA should be included by using the SQL INCLUDE statement:
exec sql include sqlda;
The SQLDA must not be defined within an SQL declare section.
The Open PL/I SQLDA template includes %REPLACE statements for the SQL data types.
/*-------------------------------------------------------------------------------- */ /* DB2 SQL Descriptor Template */ /* This should be included by the 'EXEC SQL INCLUDE SQLDA;' statement. */ /* Do not place this within an SQL declare statement. */ /*------------------------------------------------------------------------------------ */ declare 1 sqlda based(sqldaptr), */ 2 sqldaid char(8), /* Eye catcher 'SQLDA ' */ 2 sqldabc fixed bin(31), /* SQLDA size in bytes 16 + 44 * SQLN */ 2 sqln fixed bin(15), /* Number of SQLVAR elements */ 2 sqld fixed bin(15), /* Number of used SQLVAR elements */ 2 sqlvar(1:sqlsize refer(sqln)), /* Variable descriptor */ 3 sqltype fixed bin(15), /* Variable data type */ 3 sqllen fixed bin(15), /* Variable length */ 3 sqldata pointer, /* Pointer to variable data value */ 3 sqlind pointer, /* Pointer to null indicator */ 3 sqlname char(30) var; /* Variable name */ declare sqlsize fixed bin(15); /* Number of sqlvars (sqln) */ declare sqldaptr pointer; /* End of SQL Descriptor Template declaration */ /* replaces for SQL type codes */ /* replaces of the SQL_TYP_Nxxnnn means with Null indicator */ %replace SQL_TYP_DATE by 384; /* DATE */ %replace SQL_TYP_NDATE by 385; %replace SQL_TYP_TIME by 388; /* TIME */ %replace SQL_TYP_NTIME by 389; %replace SQL_TYP_STAMP by 392; /* TIMESTAMP */ %replace SQL_TYP_NSTAMP by 393; %replace SQL_TYP_VARCHAR by 448; /* VARCHAR(I) varying length string I<=4000*/41) %replace SQL_TYP_NVARCHAR by 449; %replace SQL_TYP_CHAR by 452; /* CHAR(I) - fixed length string */ %replace SQL_TYP_NCHAR by 453; %replace SQL_TYP_LONG by 456; /* LONG VARCHAR - varying length I > 4000 */ %replace SQL_TYP_NLONG by 457; %replace SQL_TYP_CSTR by 460; /* varying length string for C */ %replace SQL_TYPNCSTR by 461; %replace SQL_TYP_VARGRAPH by 464; /* VARGRAPHIC(I) - varying length */ %replace SQL_TYP_NVARGRAPH by 465; %replace SQL_TYP_GRAPHIC by 468; /* GRAPHIC(I) - fixed length graphic */ %replace SQL_TYP_NGRAPHIC by 469; %replace SQL_TYP_LONGRAPH by 472; /* LONG VARGRAPHIC(I) - varying length */ %replace SQL_TYP_NLONGRAPH by 473; %replace SQL_TYP_LSTR by 476; /* varying length string for Pascal */ %replace SQL_TYP_NLSTR by 477; %replace SQL_TYP_FLOAT by 480; /* FLOAT - 8-byte floating point */ %replace SQL_TYP_NFLOAT by 481; %replace SQL_TYP_DECIMAL by 484; /* DECIMAL (p,q), sqllen q + (256 * p) */ %replace SQL_TYP NDECIMAL by 485; %replace SQL_TYP_ZONED by 488; /* Zoned Decimal -> DECIMAL (m,n) */ %replace SQL_TYP_NZONED by 489; %replace SQL_TYP_INTEGER by 496; /* INTEGER - 4-byte signed integer */ %replace SQL_TYP_NINTEGER by 497; %replace SQL_TYP_SMALL by 500; /* SMALLINT - 2-byte signed integer*/ %replace SQL_TYP NSMALL by 501; %replace SQL_TYP_NUMERIC by 504; /* NUMERIC -> DECIMAL (m,n) */ %replace SQL_TYP_NNUMERIC by 505; /* End of EXEC SQL INCLUDE SQLDA -------------------------------------------------*/