SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
4-27
Using Indicator Variables With the INVOKE Directive
Using Indicator Variables With the INVOKE Directive
The INVOKE directive automatically generates a two-character indicator variable for
each host variable that corresponds to a column that allows null. The name of the
indicator variable is the same name as the corresponding column, plus a suffix and an
optional prefix. If you do not specify a prefix or suffix, the INVOKE statement appends
a default suffix (-I for COBOL) to the indicator variable name.
The format of the indicator variable name depends on the PREFIX, SUFFIX, and NULL
STRUCTURE clauses.
PREFIX and SUFFIX Clauses
The PREFIX and SUFFIX clauses cause the INVOKE statement to generate an
indicator variable name derived from the column name and the prefix or suffix. A
default suffix of -I applies if the INVOKE directive omits these clauses.
Table 4-5. Changes Made by INVOKE in Generated Host Variables
Column or Data Type Description of Change
Underscore (_) within a name Converts underscores to hyphens (-). For example,
the column name CITY_STREET becomes CITY-
STREET.
Underscore (_) at the end of a name Truncates the underscore so that the resulting name
does not end in a hyphen. For example, the column
name HOME_ becomes HOME.
Column with VARCHAR data type Creates a group item with two elementary data
items. The group item name is derived from the
VARCHAR column name. The data names of the
subordinate data items are:
•
LEN, a numeric data item for the length
•
VAL, a fixed-length character data item for the
string, with the maximum length specified by the
VARCHAR column definition
For example, CUSTNAME defined as VARCHAR
(26) becomes this group item:
01 CUSTNAME.
02 LEN PIC S9(4) COMP.
02 VAL PIC X(26).
DATE, TIME, TIMESTAMP, or
INTERVAL data type
If the -e preprocessor option is specified, converts
columns to character fields.
INTERVAL columns have an additional character for
a sign. (That is, a negative interval is possible.) The
format of the column is the DEFAULT format.