SQL/MP Programming Manual for COBOL85

Introduction
HP NonStop SQL/MP Programming Manual for COBOL85429326-004
1-2
Host Variables
You declare host variables in a Declare Section in the Data Division. A Declare Section
is delimited by the BEGIN DECLARE SECTION and END DECLARE SECTION
directives. In this example, FILENUMBER and MESSAGE are host variables:
DATA DIVISION.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 FILENUMBER PIC 9(6) DISPLAY.
01 MESSAGE PIC X(200).
...
EXEC SQL END DECLARE SECTION END-EXEC.
The COBOL85 compiler accepts the CHARACTER SET clause in a host variable
declaration to associate a single-byte or double-byte character set such as Kanji,
KSC5601, and ISO 8859/n with a host variable.
When you specify a host variable in an SQL statement, precede the host variable
name with a colon (:). In COBOL statements, you do not need the colon as shown:
EXEC SQL
SELECT COLUMN1 INTO :HOST-VARIABLE1 FROM =TABLEA
WHERE COLUMN1 > :HOST-VARIABLE2
END-EXEC.
MOVE HOST-VARIABLE1 TO NEW-NAME.
...
For more information, see Section 2, Host Variables.