Indicator Variables and Structures - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

Product
Preprocessor2 for Embedded SQL
Release Number
15.00
Language
English (United States)
Last Update
2018-09-27
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

Indicator Variables and Structures

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

As an example, consider the following:

01    STRUCTURE1.
      02 FIELD1      PIC X(20).
      02 FIELD2      PIC S9(9) <comp>.
      02 FIELD3      PIC X(6).
      02 FIELD4      PIC S9(11)V99 COMP-3.
01 INDSTRUCT.
      05 INDVAR OCCURS 4 TIMES PIC S9(4) <comp>.
EXEC SQL
      SELECT *
      INTO  :STRUCTURE1 :INDVAR
      FROM  table1
      WHERE col1 = :hostvar2
END-EXEC
EXEC SQL
      FETCH cursor1 INTO :STRUCTURE1 :INDVAR
END-EXEC

Where <comp> is COMP-5 for MF COBOL and COMP for all other COBOL compilers.

Note the use of INDVAR rather than INDSTRUCT to identify the indicator array.

  • The variable name which contains the OCCURS clause is always used to identify the indicator array to the precompiler.
  • In both examples, INDVAR(1) is associated with FIELD1, INDVAR(2) with FIELD2 and so on.
  • The host variable is not required to have an associated indicator variable.
  • The INDVAR array above could have had two elements rather than four.
  • PP2, however, associates host variables and indicator variables one to one in order of occurrence.
  • In these examples, FIELD1 and FIELD2 would have associated indicators, while FIELD3 and FIELD4 would have no indicators (assuming the array is defined with two elements).
  • Indicator arrays may be associated only with a structure.
  • Use of an array with individual elements results in a precompiler error.