Before you use a host variable in an Embedded SQL statement, you must declare the variable by using normal C-language syntax within an Embedded SQL host declare section. Host variable declarations start with the Embedded SQL statement BEGIN DECLARE SECTION and end with the END DECLARE SECTION statement. For example:
EXEC SQL BEGIN DECLARE SECTION;
int nID;
unsigned short usNumber;
char szName[30];
EXEC SQL END DECLARE SECTION;
Note
Embedded SQL limits the length of host variable names to 30 characters. Declaring host variables with longer names causes an error at precompile time when Embedded SQL processes the host variable.
Host variables can be declared wherever C variables can be declared. Because Embedded SQL does not attempt to parse complex C variables such as structures or arrays (other than simple character arrays), you cannot directly use structures or arrays to receive rows or columns of data. However, you can use a structure member as a host variable. You can also use a pointer to a single array element as a host variable and index that pointer as appropriate before each use.