Indicator variables, indicator arrays, and host structure indicator arrays in C and C++

An indicator variable is a 2-byte integer (short int). An indicator variable array is an array of 2-byte integers (short int). You declare indicator variables in the same way as host variables. You can mix the declarations of the two types of variables.

The following diagram shows the syntax for declaring an indicator variable in C and C++.

Read syntax diagramSkip visual syntax diagramautoexternstaticconstvolatilesignedshortint,variable-name=expression;

The following diagram shows the syntax for declaring an indicator array or a host structure indicator array in C and C++.

Read syntax diagramSkip visual syntax diagramautoexternstaticconstvolatilesignedshortint,variable-name[dimension1]=expression;
Notes:
  • 1 dimension must be an integer constant in the range 1–32767.

Example

The following example shows a FETCH statement with the declarations of the host variables that are needed for the FETCH statement and their associated indicator variables.
EXEC SQL FETCH CLS_CURSOR INTO :ClsCd,
                               :Day :DayInd,
                               :Bgn :BgnInd,
                               :End :EndInd;
You can declare these variables as follows:
EXEC SQL BEGIN DECLARE SECTION;
char  ClsCd[8];
char  Bgn[9];
char  End[9];
short Day, DayInd, BgnInd, EndInd;
EXEC SQL END DECLARE SECTION;