13.6.7 Condition Handling
- 220.127.116.11 DECLARE ... CONDITION Statement
- 18.104.22.168 DECLARE ... HANDLER Statement
- 22.214.171.124 GET DIAGNOSTICS Statement
- 126.96.36.199 RESIGNAL Statement
- 188.8.131.52 SIGNAL Statement
- 184.108.40.206 Scope Rules for Handlers
- 220.127.116.11 The MySQL Diagnostics Area
- 18.104.22.168 Condition Handling and OUT or INOUT Parameters
- 22.214.171.124 Restrictions on Condition Handling
Conditions may arise during stored program execution that require special handling, such as exiting the current program block or continuing execution. Handlers can be defined for general conditions such as warnings or exceptions, or for specific conditions such as a particular error code. Specific conditions can be assigned names and referred to that way in handlers.
To name a condition, use the
DECLARE ... CONDITION statement. To declare a handler, use the
DECLARE ... HANDLER statement. See Section 126.96.36.199, “DECLARE ... CONDITION Statement”, and Section 188.8.131.52, “DECLARE ... HANDLER Statement”. For information about how the server chooses handlers when a condition occurs, see Section 184.108.40.206, “Scope Rules for Handlers”.
To raise a condition, use the
SIGNAL statement. To modify condition information within a condition handler, use
RESIGNAL. See Section 220.127.116.11, “DECLARE ... CONDITION Statement”, and Section 18.104.22.168, “DECLARE ... HANDLER Statement”.
To retrieve information from the diagnostics area, use the
GET DIAGNOSTICS statement (see Section 22.214.171.124, “GET DIAGNOSTICS Statement”). For information about the diagnostics area, see Section 126.96.36.199, “The MySQL Diagnostics Area”.