Previous Topic: DescriptionNext Topic: Example


Processing

The types of WHENEVER statements are:

ANSI

Extended Mode

WHENEVER NOT FOUND WHENEVER SQLERROR

WHENEVER NOT FOUND WHENEVER SQLERROR WHENEVER SQLWARNING

Every executable SQL statement in a program is within the scope of one implicit or explicit WHENEVER statement of each type. The scope of a WHENEVER statement is related to the listing sequence of the statements in the program, not their execution sequence.

The scope of an exception declaration:

  1. Begins with the placement of the exception declaration in the source, and
  2. Continues until either another exception declaration in the source or the end of the source.

An SQL statement is within the scope of the last WHENEVER statement of each type specified before that SQL statement in the source program. SQL statements occurring in the source before an exception declaration are not affected by it. Any SQL statements executed that are not under control of an exception declaration default to CONTINUE. If an exception declaration is not provided, the recommended practice is that your program include code to check the SQLCODE value in the SQL Communication Area (SQLCA) immediately after each executable SQL statement.