


Preparing your ESQL source code for use with the pre-compiler is straightforward. All ESQL statement blocks must start with the keywords "EXEC SQL" and end with the keywords "END-EXEC". The structure and syntax of the SQL statements within each code block should conform to the variant of SQL required by the target database.
Note that the pre-compiler mode used to perform syntax checking can create variability with respect to errors encountered at runtime and, therefore, should be taken into consideration when you prepare your source code. For example, if you direct the pre-compiler to pass ESQL statements to the database engine for syntax checking (provided that your ODBC driver supports the return of syntax errors), you will know exactly what is acceptable and unacceptable to the database engine. This method ensures that your SQL statements are syntactically correct when the source code successfully pre-compiles. If, on the other hand, you use the pre-compiler's relaxed syntax checking mode, some of your ESQL statements will pass through the pre-compiler without any test against the syntax accepted by the target database, increasing the likelihood of undetected SQL syntax errors causing problems at runtime (for a description of the "-Pr" option, see Section 3.2.2 Invoking the Pre-compiler From the ACUCOBOL-GT Command Line).
If your program will access a DB2 database, your ESQL statements should conform to the IBM SQL standard described in IBM publication S10J-8158-00, "Embedded SQL Programming Guide, Version 5." A reference level definition of IBM SQL is included in IBM publication S10J-8165, "SQL Reference." When you pre-compile your program you will want to specify the "-Pk DB2" option to direct the pre-compiler to perform DB2-specific syntax checking, or use the "-Pc" option to have the DB2 engine perform direct validation.