Indicator Variables
An indicator variable is a 2-byte integer variable. You can use an indicator variable in an application in three ways:
• In a statement that retrieves data from the database, you can use an indicator variable to determine if its associated host variable was assigned a null.
• In a statement that writes data to the database, or to a form field, you can use an indicator variable to assign a null to the database column, form field, or table field column.
• In a statement that retrieves character (or byte) data, you can use the indicator variable as a check that the associated host variable was large enough to hold the full length of the returned string. However you can also use SQLSTATE to do this and it is the preferred method.
The base type for a null indicator variable must be the integer type short. Any type specification built up from short is legal.
Example: Type specification built from short
short ind; /* Indicator variable */
typedef short IND;
IND ind_arr[10]; /* Array of indicators */
IND *ind_ptr; /* Pointer to indicator */
The word indicator is reserved and cannot be used to define a type in a typedef statement.
When using an indicator array with a host structure, as described in Indicator Variables Usage, you must declare the indicator array as an array of short integers (or a type built up from short). In the above example, you can use the variable ind_arr as an indicator array with a structure assignment.