15.10 - Indicator Variables and Structures - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

prodname
Preprocessor2 for Embedded SQL
vrm_release
15.10
category
Programming Reference
featnum
B035-2446-035K

To facilitate use of indicator variables with host structures for output, PP2 accepts the definition of an array of small integers. For example:

struct
      {
      char     FIELD1[21];
      long     FIELD2;
      char     FIELD3[7];
      float    FIELD4;
      } STRUCTURE1;
short  INDVAR[4];
   EXEC SQL
      SELECT *
      INTO   :STRUCTURE1 :INDVAR
      FROM   table1
      WHERE  col1 = :hostvar2;
   EXEC SQL
      FETCH  cursor1
      INTO :STRUCTURE1 :INDVAR;

In both examples, INDVAR[0] is associated with FIELD1, INDVAR[1] with FIELD2 and so forth. The host variable is not required to have an associated indicator variable. The INDVAR array above could have less than four elements. However, PP2 associates host variables and indicator variables one to one in order of occurrence.

If there were two elements defined for the indicator variables in these examples, FIELD1 and FIELD2 would have associated indicators; FIELD3 and FIELD4 would not.

Indicator arrays can be associated only with a structure. Use of an array with individual elements results in a PP2 error.