Define named error conditions. This statement associates a name with a specific SQLSTATE or MariaDB error code for easier handling in stored programs.
DECLARE condition_name CONDITION FOR condition_value
condition_value:
SQLSTATE [VALUE] sqlstate_value
| mysql_error_codeThe 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 , or statement (as long as the statement is located in the same block).
Conditions must be declared after , but before and .
A condition_value for DECLARE ... CONDITION can be an 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:
For a list of SQLSTATE values and MariaDB error codes, see .
This page is licensed: GPLv2, originally from
ERROR 1407 (42000): Bad SQLSTATE: '00000'