[英]How to determine if there was an exception in the handler in MySQL?
I use handler in my function.我在我的函数中使用处理程序。 How to find out if an exception occurred while executing the handler body?如何找出执行处理程序主体时是否发生异常?
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
INSERT INTO ...
END;
You can create a HANDLER
for your exception and you can set settings or variable values as you like:您可以为您的异常创建一个HANDLER
程序,您可以根据需要设置设置或变量值:
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
SET hasError = 1;
And later you can check the value of hasError
.稍后您可以检查hasError
的值。
You can do something more complex as well in stored procedures:你也可以在存储过程中做一些更复杂的事情:
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
...
END;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.