Syntax\n------\n\nDECLARE condition_name CONDITION FOR condition_value\n\ncondition_value:\n    SQLSTATE [VALUE] sqlstate_value\n  | mysql_error_code\n\nDescription\n-----------\n\nThe DECLARE ... CONDITION statement defines a named error condition. It specifies a condition that needs specific handling and associates a name with that condition. Later, the name can be used in a DECLARE ... HANDLER, SIGNAL or RESIGNAL statement (as long as the statement is located in the same BEGIN ... END block).\n\nConditions must be declared after local variables, but before CURSORs and HANDLERs.\n\nA 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 success rather than an error condition. If you try, or if you specify an invalid SQLSTATE value, an error like this is produced:\n\n``sql\nERROR 1407 (42000): Bad SQLSTATE: '00000'\n`\n\nFor a list of SQLSTATE` values and MariaDB error codes, see MariaDB Error Codes.\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/declare-condition