Condition Handling If the  SIGNAL  statement uses a named condition, the condition must be declared in some scope that applies to the  SIGNAL  statement, and must be defined using an  SQLSTATE  value, not a MySQL error number. Example: If the named condition does not exist in the scope of the  SIGNAL  statement, an  Undefined CONDITION error occurs. If  SIGNAL  refers to a named condition that is defined with a MySQL error number rather than an SQLSTATE  value, a  SIGNAL/RESIGNAL can only use a CONDITION defined with SQLSTATE error occurs. The following statements cause that error because the named condition is associated with a MySQL error number: If a condition with a given name is declared multiple times in different scopes, the declaration with the most local scope applies. Consider the following procedure: If  divisor  is 0, the first  SIGNAL  statement executes. The innermost  my_error  condition declaration applies, raising  SQLSTATE ’22012’ . If  divisor  is not 0, the second  SIGNAL  statement executes. The outermost  my_error  condition declaration applies, raising  SQLSTATE ’45000’ . For information about how the server chooses handlers when a condition occurs, see Section 13.6.7.6, “Scope Rules for Handlers” . Signals can be raised within exception handlers: CALL p()  reaches the  DROP TABLE  statement. There is no table named  no_such_table , so the error handler is activated. The error handler destroys the original error (“no such table” ) and makes a new error with  SQLSTATE ’99999’  and message  An error occurred . 2824 CREATE PROCEDURE p () BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SIGNAL SQLSTATE VALUE ’99999’ SET MESSAGE_TEXT = ’An error occurred’; END; DROP TABLE no_such_table; END; CREATE PROCEDURE p (divisor INT) BEGIN DECLARE my_error CONDITION FOR SQLSTATE ’45000’; IF divisor = 0 THEN BEGIN DECLARE my_error CONDITION FOR SQLSTATE ’22012’; SIGNAL my_error; END; END IF; SIGNAL my_error; END; DECLARE no_such_table CONDITION FOR 1051; SIGNAL no_such_table; CREATE PROCEDURE p (divisor INT) BEGIN DECLARE divide_by_zero CONDITION FOR SQLSTATE ’22012’; IF divisor = 0 THEN SIGNAL divide_by_zero; END IF; END;