Declare section for host variables in C and C++ embedded SQL applications
EXEC SQL BEGIN DECLARE SECTION;
char varsql; /* allowed */
EXEC SQL END DECLARE SECTION;
The C or C++ precompiler only recognizes a subset of valid C or C++ declarations as valid host variable declarations. These declarations define either numeric or character variables. Host variables can be grouped into a single host structure. You can declare C++ class data members as host variables.
A numeric host variable can be used as an input or output variable for any numeric SQL input or output value. A character host variable can be used as an input or output variable for any character, date, time, or timestamp SQL input or output value. The application must ensure that output variables are long enough to contain the values that they receive.
EXEC SQL BEGIN DECLARE SECTION ;
typedef struct {
short id;
VARCHAR name[10+1];
short years;
double salary;
} staff_record;
staff_record staff_detail;
EXEC SQL END DECLARE SECTION ;
...
SELECT id, name, years, salary
FROM staff
INTO :staff_detail
WHERE id = 10;
...