You can use WHENEVER statements to program actions that you want to be executed for each subsequent embedded SQL statement.
You have the following options:
· You program actions that are executed before or after each SQL statement.
· You program error handling actions.
The WHENEVER statement must be located in the source code of the application program in front of the SQL statements that it handles. This is so that the C/C++ precompiler can generate the appropriate individual statements when the precompiler runs. The WHENEVER statement is valid for all subsequent SQL statements in the source code until another WHENEVER statement for the same condition takes over, or until the program ends.
EXEC SQL WHENEVER <condition> <action>;
Where <condition> is an error (see Handling Errors with WHENEVER Statements), or one of the following conditions:
SQLBEGIN |
The specified <action> is executed before each SQL statement. |
SQLEND |
The specified <action> is executed after each SQL statement. |
For <action>, specify one of the possible actions for the WHENEVER statement.
Example for Using WHENEVER Statements