Syntax:
DECLARE condition_name CONDITION FOR condition_value

condition_value:
    SQLSTATE [VALUE] sqlstate_value
  | mysql_error_code

The DECLARE ... CONDITION statement defines a named error condition. It
specifies a condition that needs specific handling and associates a
name with that condition. The name can be referred to in a subsequence
DECLARE ... HANDLER statement. See [HELP DECLARE HANDLER].

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

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

