Indicator Variables and Structures - Teradata Preprocessor2

Teradata® Preprocessor2 for Embedded SQL Programmer Guide

Product
Teradata Preprocessor2
Release Number
17.00
Published
June 2020
Language
English (United States)
Last Update
2020-06-19
dita:mapPath
whb1544831946911.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

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:

DCL  1   STRUCTURE1,
         2  FIELD1 CHAR(20),
         2  FIELD2 FIXED BIN(31),
         2  FIELD3 CHAR(6),
         2  FIELD4 FIXED DEC(13,2);
DCL  INDVAR(4)      FIXED BIN(15);
         EXEC SQL
            SELECT *
            INTO  :STRUCTURE1 :INDVAR
            FROM  table1
            WHERE col1 = :hostvar2;
EXEC SQL
         FETCH cursor1 INTO :STRUCTURE1 :INDVAR;

In both examples, INDVAR(1) is associated with FIELD1, INDVAR(2) with FIELD2, and so forth. 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 can be associated only with a structure. Use of an array with individual elements results in a precompiler error.