SQL/MP Programming Manual for COBOL

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL529758-003
2-22
Using Indicator Variables With the INVOKE Directive
Using Indicator Variables With the INVOKE Directive
The INVOKE directive automatically generates a two-byte indicator variable (data type
short) for each host variable that corresponds to a column that allows a null value. The
name of the indicator variable is the same name as the corresponding column plus a
prefix, if you specify one, and a suffix. If you do not specify a prefix or suffix, INVOKE
appends the default suffix -I to the name.
If a column name is 30 characters and the default indicator suffix -I is used, the -I is
truncated, and the indicator variable name is then identical to the corresponding host
variable name. To prevent this problem, use the PREFIX or NULL STRUCTURE
clause for column names that are 30 or 31 characters.
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 causes INVOKE 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. For example, if the column name
is RETIRE-DATE, the format of the indicator variable is RETIRE-DATE-I.
You can specify a suffix other than an I by specifying a SUFFIX clause with the
INVOKE statement. Or, you can replace the suffix with a prefix of your choosing by
specifying the PREFIX clause.
This INVOKE directive specifies both a prefix and a suffix for the indicator variables:
EXEC SQL INVOKE BTABLE PREFIX I- SUFFIX -END END-EXEC.
The HP COBOL compiler generates this structure:
* Record Definition for table \SYS1.$VOL1.SUBV1.BTABLE
* Definition current at 12:41:14 - 06/11/94
01 BTABLE.
02 I-ZCHAR-NULL-OK-END PIC S9(4) COMP.
02 ZCHAR-NULL-OK PIC X(10).
02 I-ZNUM-NULL-OK-END PIC S9(4) COMP.
02 ZNUM-NULL-OK PIC S9(4) COMP.
NULL STRUCTURE Clause
The NULL STRUCTURE clause causes INVOKE to generate a group item for columns
that contain the indicator variables. The group item name is derived from the column
name. For example, a column named RETIRE-DATE has this format:
02 RETIRE-DATE.
03 INDICATOR PIC S9(4) COMP.
03 VALUE PIC X(10).