Indicator variables, indicator arrays, and host structure indicator arrays in COBOL
An indicator variable is a 2-byte integer (PIC S9(4) USAGE BINARY). An indicator variable array is an array of 2-byte integers (PIC S9(4) USAGE BINARY). You declare indicator variables in the same way as host variables. You can mix the declarations of the two types of variables.
You can define indicator variables as scalar variables or as array elements in a structure form or as an array variable by using a single level OCCURS clause.
The following diagram shows the syntax for declaring an indicator variable in COBOL.
.-IS-. >>-+-01-+--variable-name--+-PICTURE-+--+----+--+-S9(4)-+--------> '-77-' '-PIC-----' '-S9999-' >--+---------------+--+-BINARY----------+-----------------------> | .-IS-. | +-COMPUTATIONAL-4-+ '-USAGE--+----+-' +-COMP-4----------+ +-COMPUTATIONAL-5-+ +-COMP-5----------+ +-COMPUTATIONAL---+ '-COMP------------' >--+-------------------------+--.------------------------------>< | .-IS-. | '-VALUE--+----+--constant-'
The following diagram shows the syntax for declaring an indicator array in COBOL.
(1) .-IS-. >>-level-1------variable-name--+-PICTURE-+--+----+--+-S9(4)-+---> '-PIC-----' '-S9999-' >--+---------------+--+-BINARY----------+-----------------------> | .-IS-. | +-COMPUTATIONAL-4-+ '-USAGE--+----+-' +-COMP-4----------+ +-COMPUTATIONAL-5-+ +-COMP-5----------+ +-COMPUTATIONAL---+ '-COMP------------' (2) >--OCCURS--dimension------+-------+-----------------------------> '-TIMES-' >--+-------------------------+--.------------------------------>< | .-IS-. | '-VALUE--+----+--constant-'
Notes:
- level-1 must be an integer between 2 and 48.
- dimension must be an integer constant between 1 and 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 :CLS-CD,
:DAY :DAY-IND,
:BGN :BGN-IND,
:END :END-IND
END-EXEC.
You can declare these variables as follows:
77 CLS-CD PIC X(7).
77 DAY PIC S9(4) BINARY.
77 BGN PIC X(8).
77 END PIC X(8).
77 DAY-IND PIC S9(4) BINARY.
77 BGN-IND PIC S9(4) BINARY.
77 END-IND PIC S9(4) BINARY.