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:

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.