Dynamic SQL
C supports dynamic SQL, and the application must contain the necessary SQL Descriptor Area (SQLDA) structures.
The SQLSTATE and SQLCODE variables are documented in “Result Code Variables” in SQL Stored Procedures and Embedded SQL (B035‑1148).
Include an SQLDA structure in one of the following ways:
EXEC SQL INCLUDE SQLDA
; the statement in the application causes PP2 to generate the structure.
The generated SQLDA structure for a C program is:
#ifndef SQLDASIZE {
struct sqlda {
unsigned char sqldaid[8];
int sqldabc;
short sqln;
short sqld;
struct sqlvar {
short sqltype;
unsigned short sqllen;
unsigned char *sqldata;
short *sqlind;
struct sqlname {
short length;
unsigned char data[30];
} sqlname;
} sqlvar[1];
};
#define SQLDASIZE(n)\
(sizeof(struct sqlda) + ((n)-1)*sizeof(struct sqlvar)
#endif
The second example dynamic program at the end of this chapter shows how to use the INCLUDE SQLDA statement.