|
|
DECLARE CONDITION
Declares a condition name for an exception condition value.
Usage
Description
A condition declaration defines an identifier that can be used as a name for exceptions and/or
SQLSTATEvalues. The identifier can be used inSIGNALandRESIGNALstatements as well as in handler declarations. This results in a code that is easier to read and understand compared with using explicitSQLSTATEvalues.A condition identifier can optionally be associated with an
SQLSTATEvalue. Using a condition identifier with an associatedSQLSTATEvalue in aSIGNALorRESIGNALstatement means that the associatedSQLSTATEvalue is signaled as well. If the condition identifier does not have an associatedSQLSTATEvalue, theSQLSTATEvalue45000is signaled.Restrictions
A condition name which represents an
SQLSTATEvalue may only be declared to represent a specificSQLSTATEvalue, i.e. it is not possible to declare a condition name to represent an exception class group. For a description of exception class groups, see DECLARE HANDLER.The scope of a condition name covers all the procedural SQL statements in the compound statement declaring it, including any other compound statements nested within it.
The general naming rules for a condition name are the same as those for other database objects.
If a condition name is declared to represent a particular
SQLSTATEvalue, another condition name cannot exist for that sameSQLSTATEvalue which has exactly the same scope.A condition name cannot be declared for an
SQLSTATEvalue with class `successful completion', this covers allSQLSTATEvalues starting with00.Notes
The
SQLSTATEvalue string is five characters long and contains only alphanumeric characters.In Mimer SQL any
SQLSTATEvalue that falls outside the range of standardSQLSTATEvalues is treated as an implementation-defined value.Standard
SQLSTATEvalues begin with the charactersA-I,S,0-4and7, while implementation-definedSQLSTATEvalues begin with the charactersJ-R,T-Z,5-6and8-9.Example
DECLARE invalid_parameter CONDITION; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN DECLARE condition_name VARCHAR(128); GET EXCEPTION 1 condition_name = CONDITION_IDENTIFIER; IF condition_name = 'invalid_parameter' THEN ... END IF; END; SIGNAL invalid_parameter;For more information, see Return Status and Conditions or Mimer SQL Programmer's Manual, Declaring Condition Names.
For information about the
SIGNALstatement, see SIGNAL. For information about theRESIGNALstatement, see RESIGNAL.Standard Compliance
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|