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
. RESIGNAL
。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语句”。
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诊断区域”。