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 may be specified wherever a C statement may be specified within a C function block, as the Adabas SQL Gateway 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 apply to C macro bodies.

The INCLUDE SQLCA statement may be positioned anywhere a C variable declaration could 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 may be coded anywhere in the C program.

Comments

SQL statements may 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 may not 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;