602SQL Documentation Index  

Exception Declaration (SQL)

exception_declaration ::= DECLARE identifier CONDITION [ FOR SQLSTATE [ VALUE ] sqlstate ];

This declaration defines an exception designated by the specified identifier. A declared condition may be raised by calling the SIGNAL statement and may be assigned a handler in the handler declaration.

If the character string sqlstate is specified, the declared exception is bound to this sqlstate. The handler declared for this exception will be valid for the situation described by the specified sqlstate. The same sqlstate may not be used in multiple exceptions declared with the same validity extent.

An exception without a sqlstate is executed explicitly by calling the SIGNAL statement. This can be used to leave an order of statements, one or more statement blocks or one or more routines.

Global exceptions are declared in the Module_globals procedure.