MySQL事务没有回滚错误(MySQL transaction not rolling back on error)
我的过程是这样的:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
select varerrmsg as ErrorMsg;
ROLLBACK;
END;
START TRANSACTION;
SELECT ...
INSERT ...
UPDATE ...
INSERT ...
(basically serveral statements)
CALL sp_myProc (param1, param2);
COMMIT;
我的问题是sp_myProc实际上需要3个参数,并且在我知道这个之前的测试期间,即使内部proc甚至没有启动,事务也在工作。 交易提交很奇怪,但我仍然得到ErrorMsg作为结果告诉我处理程序正在触发,但没有回滚。
我的问题是:为什么?
My proc goes something like this:
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
select varerrmsg as ErrorMsg;
ROLLBACK;
END;
START TRANSACTION;
SELECT ...
INSERT ...
UPDATE ...
INSERT ...
(basically serveral statements)
CALL sp_myProc (param1, param2);
COMMIT;
My problem is that sp_myProc actually requires 3 parameters and during testing before I knew this, the transaction was working even though the internal proc wasn even starting. Its odd that the transaction was committing, but I was still getting the ErrorMsg as a result which tells me that the handler is firing, but not rolling back.
My question is: why?
原文:/questions/37176153
-02-07 21:31
满意答案
这是我在我的存储过程中使用的一个对我有用的事务。
DECLARE exit handler for sqlexception
BEGIN
-- ERROR
SHOW ERRORS;
ROLLBACK;
END;
DECLARE exit handle