You can include files of terminal or ANSI format in your ESQL source by using the SQL INCLUDE statement.

The standard SQLCA and SQLDA INCLUDE files are built into the pre-compiler and are included whenever they are named in the source, as in:

* Include the SQL Communications Area (SQLCA)

These files include specific adaptations for AcuSQL.

Note: Do not attempt to substitute other versions of these files.

User-defined INCLUDE files must begin with an SQL BEGIN DECLARE statement and end with an SQL END DECLARE statement if the code is to be used as ESQL code. Variables not within the BEGIN/END DECLARE cannot be used as host variables. They can still be used as local variables. See Host Variables for additional information.

In statements of the form:


the compiler adds to filename the standard file extension for COBOL source files (the default is .cbl). To specify another extension, or to exclude an extension, filename must be enclosed in either single or double quotation marks. For example:


If the user-defined INCLUDE files do not reside in the current directory, you must indicate where they’re located using the -Pi compiler option or ACUSQL_INCLUDE environment variable.

SQL Communications Area (SQLCA)

The SQLCA is a COBOL group item that is used to provide information to your ESQL/COBOL program. The SQLCA contains data items for error checking, warnings, and status information that is updated whenever an ESQL statement is executed. Your COBOL program can check this structure after each ESQL operation or in a centralized error-checking routine if you are using the WHENEVER directive in your application. See Checking Syntax and WHENEVER Directive for information on the WHENEVER directive.

The field most commonly used in the SQLCA group item is SQLCODE, which contains the status of the last statement executed. SQLCODE can contain the following values:

0 The executed statement succeeded without an error or warning.
>0 The executed statement succeeded, but there was a warning. Check the other fields in the SQLCA structure to determine the nature of the warning.
<0 The executed statement encountered an error. Check the other fields in the SQLCA structure to determine the nature of the error.

If SQLCODE contains a non-zero value, your application can check the value of SQLERRMC for the text associated with the error or warning, and, when appropriate, display that text as an error message or warning.

SQL Descriptor Area (SQLDA)

The SQLDA is a COBOL group item used in performing dynamic SQL operations. SQLDA is used to store information about the input and output variables of dynamically prepared SQL statements.