Previous Topic: Displaying SQL Communication Area FieldsNext Topic: Checking Specific Errors


Error Handling

Using WHENEVER SQLERROR

If the program handles most or all errors by branching to one routine, consider using the WHENEVER precompiler directive statement that specifies the SQLERROR condition. The precompiler adds the logic requested by a WHENEVER statement immediately after every SQL statement that follows the WHENEVER statement.

In this example, if an SQL statement that follows the WHENEVER statement returns an error, processing branches to the routine labeled ERROR-EXIT:

EXEC SQL
   WHENEVER SQLERROR GOTO :ERROR-EXIT
END-EXEC.

Overriding WHENEVER

Once the program issues a WHENEVER SQLERROR statement, it can override the statement only with:

Note: For more information about the WHENEVER statement, see the CA IDMS SQL Reference Guide.