13.6.7 Condition Handling DECLARE ... CONDITION Syntax DECLARE ... HANDLER Syntax GET DIAGNOSTICS Syntax RESIGNAL Syntax SIGNAL Syntax Scope Rules for Handlers The MySQL Diagnostics Area

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, “DECLARE ... CONDITION Syntax”, and Section, “DECLARE ... HANDLER Syntax”. For information about how the server chooses handlers when a condition occurs, see Section, “Scope Rules for Handlers”.

To raise a condition, use the SIGNAL statement. To modify condition information within a condition handler, use RESIGNAL. See Section, “DECLARE ... CONDITION Syntax”, and Section, “DECLARE ... HANDLER Syntax”.

To retrieve information from the diagnostics area, use the GET DIAGNOSTICS statement (see Section, “GET DIAGNOSTICS Syntax”). For information about the diagnostics area, see Section, “The MySQL Diagnostics Area”.