|
|
DECLARE HANDLER
Declares an exception handler.
Usage
Description
An exception handler may be declared to respond to a specific exception condition or one or more of the exception class groups
SQLEXCEPTION,SQLWARNINGorNOT FOUND. An exception handler that responds to one or more exception class groups is called a general exception handler.A specific exception condition may be specified by using an
SQLSTATEvalue or a condition name, see DECLARE CONDITION. An exception handler that responds to one or more specific exception conditions is called a specific exception handler.The keywords
CONTINUE,EXITandUNDOaffect the flow of control behavior subsequent to the execution of the exception handler.If
CONTINUEis specified, the flow of control continues by executing the SQL statement immediately following the statement that raised the error, after the handler has executed.If
EXITis specified, the flow of control exits the compound statement within which the exception handler is declared after the handler has executed.If
UNDOis specified, all the changes made by the SQL statements in theATOMICcompound statement, within which the handler is declared, (or by any SQL statements triggered by those changes) are cancelled. Then the handler is executed and the flow of control exits the compound statement.Restrictions
An
UNDOexception handler can only be declared within anATOMICcompound statement.An exception handler must be either a general or a specific exception handler, it cannot respond to both an exception class group and a specific exception condition.
The same exception condition must not be specified more than once, whether by
SQLSTATEvalue or by condition name, in an exception handler declaration.Within a given scope, only one specific exception handler may be declared for a particular exception condition.
If
stringis specified, it must have length five and contain only alphanumeric characters.Notes
Within a given compound statement, if both a general and a specific exception handler have been declared to respond to a given exception condition, the specific exception handler will handle the exception.
If no exception handlers have been declared to respond to an exception condition in the compound statement within which the error was raised, the exception condition is propagated out to the enclosing compound statement or to the calling environment.
The above does not apply to exception conditions with the
NOT FOUNDandSQLWARNINGclass, these are not propagated by the exception handling mechanism in absence of an exception handler defined to handle them.
SQLWARNINGcoversSQLSTATEvalues beginning with01.
NOT FOUNDcoversSQLSTATEvalues beginning with02.
SQLEXCEPTIONcovers all otherSQLSTATEvalues (including implementation-defined values), except those beginning with00.Example
S1: BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ... ... END; ... ... END S1;For more information, see Return Status and Conditions or the Mimer SQL Programmer's Manual, Declaring Exception Handlers.
Standard Compliance
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|