https://blog.csdn.net/weixin_39718665/article/details/78166008 Mysql错误码重要的几个 1049 数据库不存在
1051 数据表不存在
1054 字段不存在
异常捕获异常条件类型##字符串类型的错误码
SQLSTATE sqlstate_value
##数值类型的错误码
mysql_error_code
异常的定义DECLARE condition_name CONDITION FOR [condition_type]
异常的捕获DECLARE handler_type HANDLER FOR condition_value [...]
handler_type 产生异常做什么操作 continue 跳过异常继续执行 exit 退出 condition_value 异常条件类型 例子create PROCEDURE show_user(out code_num int)
BEGIN
DELCARE no_table condition for 1054;
DECLARE CONTINUE HANDLER FOR no table;
set code_num=1;
select user1 from login;
end;
call show_user(@aa) ;
select @aa;
|