Syntax:
DECLARE condition_name CONDITION FOR condition_value

condition_value:
    mysql_error_code
  | SQLSTATE [VALUE] sqlstate_value

The DECLARE ... CONDITION statement declares a named error condition,
associating a name with a condition that needs specific handling. The
name can be referred to in a subsequent DECLARE ... HANDLER statement
(see [HELP DECLARE HANDLER]).

Condition declarations must appear before cursor or handler
declarations.

The condition_value for DECLARE ... CONDITION can be a MySQL error code
(a number) or an SQLSTATE value (a 5-character string literal). You
should not use MySQL error code 0 or SQLSTATE values that begin with
'00', because those indicate success rather than an error condition.
For a list of MySQL error codes and SQLSTATE values, see
http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html.

URL: http://dev.mysql.com/doc/refman/5.5/en/declare-condition.html

