MySQL has been supporting stored procedures since MySQL 5.0 and has been using the latest version of MySQL 5.5 for several years. Although the exception handling in MYSQL is not perfect, it is sufficient to handle most applications.
Exception Handling statements include the following:
1. DECLARE... CONDITION.
2. DECLARE... HANDLER.
3. RESIGNAL.
4. SIGNAL.
The first type is the condition declaration.
DECLARE condition_name condition for condition_value
Here, condition_name is the standard variable name, And condition_value is the SQLSTATE value or MySQL's own error code.
Separate condition statements cannot be run directly. It can only be part of the second type.
The second type is conditional processing.
The first statement is ready, and the next step is to handle it.
DECLARE handler_action HANDLER
FOR condition_value [, condition_value]...
Statement
Handler_action:
CONTINUE
| EXIT
| UNDO
Condition_value:
Mysql_error_code
| SQLSTATE [VALUE] sqlstate_value
| Condition_name
| SQLWARNING
| NOT FOUND
| SQLEXCEPTION
Handler_action indicates the action to be processed. Currently, there are two valid actions: continue and exit directly.
There are several condition_value types, including SQLSTATE, mysql eeror code, condition_name in the preceding condition Declaration, and other two types of range obfuscation.
SQLWARNING and SQLEXCEPTION. not found indicate any nonexistent WARNING or ERROR.
Third, it indicates the error information and code of the disguised system, and refresh the current warning buffer area.
RESIGNAL [condition_value]
[SET signal_information_item
[, Signal_information_item]...]
Condition_value:
SQLSTATE [VALUE] sqlstate_value
| Condition_name
Signal_information_item:
Condition_information_item_name = simple_value_specification
Condition_information_item_name:
CLASS_ORIGIN
| SUBCLASS_ORIGIN
| MESSAGE_TEXT
| MYSQL_ERRNO
| CONSTRAINT_CATALOG
| CONSTRAINT_SCHEMA
| CONSTRAINT_NAME
| CATALOG_NAME
| SCHEMA_NAME
| TABLE_NAME
| COLUMN_NAME
| CURSOR_NAME
Note that there are a lot of specific things that can be disguised, including the error code (MYSQL's own stuff), error content, wrong database name, table name, column name, and so on.