3. Embedded SQL for COBOL : Preprocessor Operation : Coding Requirements for Embedded SQL Programs : Embedded SQL Statements That Do Not Generate Code
 
Share this page                  
Embedded SQL Statements That Do Not Generate Code
The following embedded SQL declarative statements do not generate any COBOL code:
declare cursor
declare statement
declare table
whenever
Do not code these statements as the only statements in COBOL constructs that do not allow null statements. Also, these statements must not contain labels. For example, coding a declare cursor statement as the only statement in a COBOL IF statement causes compiler errors:
IF USING-DATABASE=1 THEN
    EXEC SQL DECLARE empcsr CURSOR FOR
         SELECT ename FROM employee END-EXEC
ELSE
    DISPLAY "You have not accessed the database".
The code generated by the preprocessor is:

IF USING-DATABASE=1 THEN
ELSE
    DISPLAY "You have not accessed the database".
This is an illegal use of the COBOL ELSE clause.
Also, do not precede these statements (declare cursor, declare statement, declare table, and whenever) with a COBOL paragraph label (on the same line) if that label is referenced elsewhere in your program.