13.6.7 Condition Handling条件处理

13.6.7.1 DECLARE ... CONDITION Statement语句
13.6.7.2 DECLARE ... HANDLER Statement语句
13.6.7.3 GET DIAGNOSTICS Statement语句
13.6.7.4 RESIGNAL Statement语句
13.6.7.5 SIGNAL Statement语句
13.6.7.6 Scope Rules for Handlers处理程序的作用域规则
13.6.7.7 The MySQL Diagnostics AreaMySQL诊断区域
13.6.7.8 Condition Handling and OUT or INOUT Parameters条件处理和输出或输入参数

Conditions may arise during stored program execution that require special handling, such as exiting the current program block or continuing execution. 存储程序执行过程中可能出现需要特殊处理的情况,例如退出当前程序块或继续执行。Handlers can be defined for general conditions such as warnings or exceptions, or for specific conditions such as a particular error code. 可以为一般条件(如警告或异常)或特定条件(如特定错误代码)定义处理程序。Specific conditions can be assigned names and referred to that way in handlers.可以为特定条件指定名称,并在处理程序中以这种方式引用。

To name a condition, use the DECLARE ... CONDITION statement. 要命名条件,请使用DECLARE ... CONDITION语句。To declare a handler, use the DECLARE ... HANDLER statement. 要声明处理程序,请使用DECLARE ... HANDLER语句。See Section 13.6.7.1, “DECLARE ... CONDITION Statement”, and Section 13.6.7.2, “DECLARE ... HANDLER Statement”. 请参阅第13.6.7.1节,“DECLARE ... CONDITION语句”第13.6.7.2节,“DECLARE ... HANDLER语句”For information about how the server chooses handlers when a condition occurs, see Section 13.6.7.6, “Scope Rules for Handlers”.有关发生条件时服务器如何选择处理程序的信息,请参阅第13.6.7.6节,“处理程序的作用域规则”

To raise a condition, use the SIGNAL statement. 要提出条件,请使用SIGNAL语句。To modify condition information within a condition handler, use RESIGNAL. 要修改条件处理程序中的条件信息,请使用RESIGNALSee Section 13.6.7.1, “DECLARE ... CONDITION Statement”, and Section 13.6.7.2, “DECLARE ... HANDLER Statement”.请参阅第13.6.7.1节,“DECLARE ... CONDITION语句”第13.6.7.2节,“DECLARE ... HANDLER语句”

To retrieve information from the diagnostics area, use the GET DIAGNOSTICS statement (see Section 13.6.7.3, “GET DIAGNOSTICS Statement”). 要从诊断区域检索信息,请使用GET DIAGNOSTICS语句(请参阅第13.6.7.3节,“GET DIAGNOSTICS语句”)。For information about the diagnostics area, see Section 13.6.7.7, “The MySQL Diagnostics Area”.有关诊断区域的信息,请参阅第13.6.7.7节,“MySQL诊断区域”

13.6.7.1 DECLARE ... CONDITION Statement
13.6.7.2 DECLARE ... HANDLER Statement
13.6.7.3 GET DIAGNOSTICS Statement
13.6.7.4 RESIGNAL Statement
13.6.7.5 SIGNAL Statement
13.6.7.6 Scope Rules for Handlers
13.6.7.7 The MySQL Diagnostics Area
13.6.7.8 Condition Handling and OUT or INOUT Parameters