General Rules in COBOL

SQL Statement Delimiters

SQL statements are delimited by the prefix EXEC SQL and the terminator END-EXEC. The prefix may be written in upper or lower case letters. In Adabas SQL Gateway Embedded SQL mode, upper or lower case is permitted and the prefix may be split over numerous lines, separated by any whitespace character. In ANSI mode, upper case is required and only whitespaces may separate the prefix keywords.

The terminator END-EXEC may be followed by an optional period (.). It has to be coded on the same line to be recognized.

SQL Statement Placement

All SQL statements with the exception of the BEGIN/END DECLARE and INCLUDE statements may be specified wherever a COBOL statement may be specified within the Procedure Division of the embedded SQL COBOL program. Included COBOL source code must not contain any SQL statements or any host variable declaration to be used in SQL statements.

The SQL INCLUDE , BEGIN/END DECLARE statements must be specified in the WORKING STORAGE SECTION of the COBOL program.

Comments

SQL statements may contain COBOL comments marked with an asterisk in column 7 or SQL comments preceded by two minus characters.

 

COBOL Example :

000015     EXEC SQL WHENEVER SQLERROR

000016*                               CONTINUE

000017                                GOTO HANDLE-ERROR

000018     END-EXEC.

 

SQL Example :

000015     EXEC SQL WHENEVER SQLERROR

000016                             -- CONTINUE

000017                                GOTO HANDLE-ERROR

000018     END-EXEC.