13.6.8 Restrictions on Condition Handling条件处理的限制

SIGNAL, RESIGNAL, and GET DIAGNOSTICS are not permissible as prepared statements. 不允许将SIGNALRESIGNALGET DIAGNOSTICS作为准备好的声明。For example, this statement is invalid:例如,此语句无效:

PREPARE stmt1 FROM 'SIGNAL SQLSTATE "02000"';

SQLSTATE values in class '04' are not treated specially. '04'中的SQLSTATE值没有经过特殊处理。They are handled the same as other exceptions.它们的处理方式与其他异常相同。

In standard SQL, the first condition relates to the SQLSTATE value returned for the previous SQL statement. 在标准SQL中,第一个条件与前一条SQL语句返回的SQLSTATE值有关。In MySQL, this is not guaranteed, so to get the main error, you cannot do this:在MySQL中,这是不能保证的,所以要获取主要错误,您不能这样做:

GET DIAGNOSTICS CONDITION 1 @errno = MYSQL_ERRNO;

Instead, do this:相反,要这样做:

GET DIAGNOSTICS @cno = NUMBER;
GET DIAGNOSTICS CONDITION @cno @errno = MYSQL_ERRNO;