8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

15.6.7 条件处理15.6.7 Condition Handling

条件,在需要特殊处理的存储程序执行过程中出现,例如退出当前程序块或继续执行。处理程序可以定义为一般条件,如警告或异常,也可以定义特定条件,如特定错误代码。特定条件可以被赋予名称,并在处理程序中以此方式引用。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.

要命名条件,请使用 DECLARE ... CONDITION 语句。要声明一个处理程序,请使用 DECLARE ... HANDLER 语句。参见 第 15.6.7.1 节,“DECLARE ...CONDITION 语句“,以及 第 15.6.7.2 节,”声明 ...HANDLER 语句“。关于服务器在条件发生时如何选择处理程序的信息,请参见 第 15.6.7.6 节,”Scope Rules for Handlers“。To name a condition, use the DECLARE ... CONDITION statement. To declare a handler, use the DECLARE ... HANDLER statement. See Section 15.6.7.1, “DECLARE ... CONDITION Statement”, and Section 15.6.7.2, “DECLARE ... HANDLER Statement”. For information about how the server chooses handlers when a condition occurs, see Section 15.6.7.6, “Scope Rules for Handlers”.

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

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