Handling Errors

From InterBase

Go Up to Working with Stored Procedures


Procedures can handle three kinds of errors with a WHEN … DO statement:

  • Exceptions raised by EXCEPTION statements in the current procedure, in a nested procedure, or in a trigger fired as a result of actions by such a procedure.
  • SQL errors reported in SQLCODE.
  • InterBase errors reported in GDSCODE.

The WHEN ANY statement handles any of the three types of errors.

For more information about InterBase error codes and SQLCODE values, see the Language Reference.

The syntax of the WHEN … DO statement is:

WHEN {<error> [, <error> …] | ANY}
DO <compound_statement>
<error>; =
{EXCEPTION exception_name | SQLCODE number | GDSCODE errcode}
Important:
If used, WHEN must be the last statement in a BEGIN … END block. It should come after SUSPEND, if present.

Topics

Advance To: