Null Indicator Arrays and Host Structures
Use host structures to hold the data to be retrieved or written by SELECT, FETCH, and INSERT statements. In combination with host structures, an indicator array can be used to detect whether a particular member of the host structure contains a null.
An indicator array is an array of 2‑byte integers that is associated with a host variable structure. Generally, indicator arrays are declared in the same declare section as their associated host variable structure. For example, the following code declares a host variable structure, emprec, and its associated indicator array, empind:
emprec
ename character(20),
eid integer,
esal float;
empind array(3) of short_integer;
The preceding structure and indicator array might be used as follows:
exec sql select name, id, sal
into :emprec:empind
from employee
where number = 12;
A particular element of the indicator array is associated with the corresponding ordered member of the host structure: you do not need to specify each array element separately. The embedded OpenSQL preprocessor enumerates the elements in the array when expanding the structure into its members.
Last modified date: 08/14/2024