COBOL and Host Variables - 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

COBOL and Host Variables

Any valid COBOL host variable can be used in a SQL statement. However, this does not mean that all variables can be used. Host variables must meet certain requirements before PP2 accepts them as usable in SQL statements. See “Host Variable Declaration” on page 167.

Define host variables outside a structure at level 01 or 77. Host variables within a structure can be level 02 through 48. Level 49 is reserved for varying character fields. Level 66 and 88 items are ignored.

Any valid COBOL variable name can be used as a host variable name, including names with embedded hyphens.

Precede all host variable names with a colon, when the host variable:

  • Begins with a number
  • Is used for input in situations where the Teradata Database expects a numeric constant
  • The USAGE IS DISPLAY clause is accepted only for a host variable of character type (PIC X(n)).

    The following clauses invalidate a host variable definition for use in an embedded SQL statement:

  • BLANK
  • WHEN ZERO
  • JUSTIFIED
  • SIGN
  • Host variables which are not SQL strings are used only to represent data values. Do not use them to represent database, table, view, macro or column names.

    Declare host variables in the WORKING STORAGE SECTION or the LINKAGE SECTION of the COBOL program.

    Variables declared elsewhere are not valid.