SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
3-37
Using Indicator Variables With the INVOKE Directive
Using Indicator Variables With the INVOKE Directive 
The INVOKE directive automatically generates a two-character indicator variable with 
data type short for each host variable that corresponds to a column that allows null. 
The name of the indicator variable is the same name as the corresponding column, 
plus a suffix and a prefix. If you do not specify a prefix or suffix, the INVOKE statement 
appends a default suffix (_i for C) to the indicator variable name. 
The format of the indicator variable name depends on the PREFIX, SUFFIX, and NULL 
STRUCTURE clauses. 
PREFIX and SUFFIX Clauses
The PREFIX and SUFFIX clauses cause the INVOKE statement to generate an 
indicator variable name derived from the column name and the prefix or suffix. A 
default suffix of _i applies if the INVOKE directive omits these clauses. 
Example
The table named c_table has the columns empnum and empname. The column 
empname can be null. This example uses an INVOKE statement with both the PREFIX 
and SUFFIX clauses:
EXEC SQL BEGIN DECLARE SECTION;
 EXEC SQL INVOKE c_table PREFIX beg_ SUFFIX _end;
 struct c_table_type mytable; 
 ...
EXEC SQL END DECLARE SECTION;
The SQL C preprocessor generates this structure immediately after the INVOKE 
directive in the preprocessed program code:
/* Beginning of generated code for SQL INVOKE */
 struct c_table_type {
 long empnum;
 short beg_empname_end;
 char empname[16];
 };
In this example, the structure name defaults to the simple name of the table or view 
with the suffix _type appended. The structure name is c_table_type.
You must declare a variable of the struct type so that you can use that variable in 
your C language statements and your embedded SQL statements. In this example, the 
declared struct variable is named mytable.
NULL STRUCTURE Clause
The NULL STRUCTURE clause causes the INVOKE statement to generate a structure 
for a column that allows null. It assigns the same name as the column to the structure. 
The structure includes fields for the data item, named valu, and its indicator variable, 
named indicator.
C










