General Rules in C
SQL Statement Delimiters
SQL statements are delimited by the prefix EXEC SQL and a semicolon (;), which acts as the terminator. The prefix may be written in upper or lower case letters.
SQL Statement Placement
SQL statements can be specified wherever a C statement can be specified within a C function block, as the CONNX Embedded SQL compiler replaces them with generated C statements. Included C source code must not contain any SQL statements, nor any host variable declaration for use in SQL statements. Similar restriction applies to C macro bodies.
The INCLUDE SQLCA statement can be positioned anywhere a C variable declaration can be positioned. As this statement results in a declaration of an SQLCA structure, it must be positioned to be in scope for any statement using this SQLCA declaration. The C scoping rules apply.
The SQL WHENEVER statement can be coded anywhere in the C program.
Comments
SQL statements can contain C comments wherever a blank is permitted, C++ comments, or SQL comments which extend to the end of the current source line. Comments are not allowed in strings and cannot be nested.
C example:
EXEC SQL WHENEVER SQLERROR
/* CONTINUE */
GOTO HANDLE-ERROR;
C++ example:
EXEC SQL WHENEVER SQLERROR
// CONTINUE */
SQL example:
EXEC SQL WHENEVER SQLERROR
-- CONTINUE
GOTO HANDLE-ERROR;