15.10 - Using COBOL Structures as Input Host Variables - 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

The following rules apply to using host variables in a COBOL program:

  • Do not use the keyword FILLER in a structure other than a varying character field, otherwise the structure as a whole is invalidated. Instead, reference valid individual fields.
  • Use host structures to insert data into Teradata Database managed databases.
  • This feature is useful for an INSERT with a VALUES clause that inserts multiple fields into a table using host variables.

  • A host structure as an entity is valid for input only if all fields of the structure are validly defined.
  • All of the fields of the structure are passed to the Teradata Database, therefore the application must ensure that the structure elements match the number of elements specified in the SQL statement.

  • Do not use a structure reference as an input entity in a WHERE clause or any place where a single field is expected.
  • Using individual fields of a structure for input is valid if the fields are defined following PP2 rules.
  • PP2 supports structured host variables to a depth of two, following the same rules as SQL/DS and DB2.
  • Qualified references in embedded SQL statements are expressed using PL/I syntax; that is, with a dot separating the levels of qualification.
  • A typical host structure definition takes the following form:
  • 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.

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

    This is one of several ways to declare a structure. Other valid forms are described in “Host Variable Declaration” on page 163.

    The structure level can go deeper than the two levels shown, but the items, if individually referenced, must be uniquely identifiable with a qualification depth of no more than two.