Host variables are the key to communication in an ESQL application. These are data items in Working-Storage that are made available to ESQL for communicating information to and from the database. Put another way, host variables can provide input to your ESQL program and the program can return information to host variables.
Host variables are standard COBOL Working-Storage items that are enclosed by BEGIN/END DECLARE statements. For example:
EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 EMPLOYEE-NAME. 03 FIRST-NAME PIC X(20). 03 LAST-NAME PIC X(20). EXEC SQL END DECLARE SECTION END-EXEC.
This makes the variables FIRST-NAME and LAST-NAME available to the AcuSQL pre-compiler. When these variables are used in the Procedure Division in an SQL statement, they must be preceded by a colon (:). This differentiates host variables from local data objects with the same name. If you are using the variables in COBOL operations (rather than SQL operations), the colon should not be used. The pre-compiler recognizes COBOL variables only if they have been declared in an SQL BEGIN DECLARE section. See Host Variables for a further discussion of host variables.