DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND
BEGIN
ROLLBACK;
END;
START TRANSACTION;
UPDATE tbl_order SET TransactionID="abc" WHERE OrderID=1;
UPDATE tbl_order SET TransactionID="xyz" WHERE OrderID=;
UPDATE tbl_order SET TransactionID="zzz" WHERE OrderID=13;
COMMIT;
由于某种原因,订单1和13被填充而没有回滚,并且我得到了退出hadler的语法错误。
Query: DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND BEGIN ROLLBACK
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND
BEGIN
ROLLBACK' at line 1
有人可以帮助我弄清楚我在做什么错吗?
提前致谢
编辑
UPDATE tbl_order SET TransactionID =“xyz” WHERE OrderID =;
是故意的
最佳答案
我相信导出处理程序只能在存储过程中使用。该文档没有明确说明这一点,但暗示
http://dev.mysql.com/doc/refman/5.1/en/condition-handling.html
关于mysql事务错误处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9105533/