最佳答案
您可以尝试使用SHOW ERROR和SHOW WARNING.要查看上一个错误或警告,您可以将其用作:
原文链接:https://www.f2er.com/mysql/433096.htmlSHOW ERRORS LIMIT 1 -- for sql-state > 2
SHOW WARNINGS LIMIT 1 -- for sql-state 1,2
sqlWARNING is shorthand for the class of sqlSTATE values that begin
with ’01’.NOT FOUND is shorthand for the class of sqlSTATE values that begin
with ’02’. This is relevant only within the context of cursors and is
used to control what happens when a cursor reaches the end of a data
set. If no more rows are available,a No Data condition occurs with
sqlSTATE value 02000. To detect this condition,you can set up a
handler for it (or for a NOT FOUND condition). An example is shown in
Section 12.7.5,“Cursors”. This condition also occurs for SELECT …
INTO var_list statements that retrieve no rows.sqlEXCEPTION is shorthand for the class of sqlSTATE values that do not
begin with ’00’,’01’,or ’02’.
因此,要处理异常,您只需执行以下操作:
DECLARE EXIT HANDLER FOR sqlSTATE sqlEXCEPTION .....;
链接: