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-28
Using Indicator Variables With the INVOKE Directive
Example
A table named cob_table has the columns empnum and empname. The column
empname can be null. This example uses an INVOKE statement with both the PREFIX
and SUFFIX clauses:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
EXEC SQL INVOKE cob_table PREFIX BEG- SUFFIX -END END-EXEC.
...
EXEC SQL END DECLARE SECTION END-EXEC.
The SQL COBOL preprocessor generates this record description immediately after the
INVOKE directive in the preprocessed program code:
* Record Definition for table COB_TABLE
01 COB-TABLE.
02 EMPNUM PIC 9(4) COMP.
02 BEG-EMPNAME-END PIC S9(4) COMP.
02 EMPNAME PIC X(10).
NULL STRUCTURE Clause
The NULL STRUCTURE clause causes the INVOKE statement to generate a group
item for a column that allows null. The group item name is the same as the column
name. The group item includes fields for the data item, named VALU, and its indicator
variable, named INDICATOR.
Example
A database contains an EMPTBL table consisting of the columns EMPNUM,
FIRST_NAME, LAST_NAME, and HIRE_DATE. The columns FIRST_NAME and
HIRE_DATE allow null. This example uses an INVOKE statement with the NULL
STRUCTURE clause:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
EXEC SQL INVOKE EMPTBL AS EMPTBL-REC NULL STRUCTURE END-EXEC.
...
EXEC SQL END DECLARE SECTION END-EXEC.
The SQL/MX COBOL preprocessor generates this record description immediately after
the INVOKE statement in the preprocessed program code:
* Record Definition for table EMPTBL
01 EMPTBL-REC.
02 EMPNUM PIC 9(4) COMP.
02 FIRST-NAME.
03 INDICATOR PIC S9(4) COMP.
03 VALU PIC X(15).
02 LAST-NAME PIC X(20).
02 HIRE-DATE.
03 INDICATOR PIC S9(4) COMP.
03 VALU PIC X(10).
COBOL
COBOL