Condition Handling • SQLEXCEPTION : Shorthand for the class of SQLSTATE values that do not begin with  ’00’ ,  ’01’ , or ’02’ . •For  SQLEXCEPTION  conditions, the stored program terminates at the statement that raised the condition, as if there were an  EXIT  handler. If the program was called by another stored program, the calling program handles the condition using the handler selection rules applied to its own handlers. •For  SQLWARNING  conditions, the program continues executing, as if there were a  CONTINUE  handler. •For  NOT FOUND  conditions, if the condition was raised normally, the action is  CONTINUE . If it was raised by  SIGNAL  or  RESIGNAL , the action is  EXIT . 2809 DECLARE CONTINUE HANDLER FOR SQLWARNING BEGIN END; To ignore a condition, declare a  CONTINUE  handler for it and associate it with an empty block. For example: Notice that  @x  is  3  after the procedure executes, which shows that execution continued to the end of the procedure after the error occurred. If the  DECLARE ... HANDLER  statement had not been present, MySQL would have taken the default action ( EXIT ) after the second  INSERT  failed due to the  PRIMARY KEY  constraint, and  SELECT @x  would have returned  2 . The following example uses a handler for  SQLSTATE ’23000’ , which occurs for a duplicate-key error: If a condition occurs for which no handler has been declared, the action taken depends on the condition class: For information about how the server chooses handlers when a condition occurs, see Section 13.6.7.6, “Scope Rules for Handlers” . DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN -- body of handler END; mysql>  CREATE TABLE test.t (s1 INT, PRIMARY KEY (s1)); Query OK, 0 rows affected (0.00 sec) mysql>  delimiter // mysql>  CREATE PROCEDURE handlerdemo () BEGIN DECLARE CONTINUE HANDLER FOR SQLSTATE ’23000’ SET @x2 = 1; SET @x = 1; INSERT INTO test.t VALUES (1); SET @x = 2; INSERT INTO test.t VALUES (1); SET @x = 3; END; // Query OK, 0 rows affected (0.00 sec) mysql>  CALL handlerdemo()// Query OK, 0 rows affected (0.00 sec) mysql>  SELECT @x// +------+ | @x | +------+ | 3 | +------+ 1 row in set (0.00 sec)