Mysql存储过程中的事务回滚

create procedure test(in a int)
    BEGIN
        DECLARE t_error INTEGER DEFAULT 0;
        DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1;-- 异常时设置为1
        START TRANSACTION;
        INSERT into aaaa VALUES(2,3);
        INSERT into aaaaa VALUES(2,3);
        IF t_error = 1 THEN
            ROLLBACK;
        ELSE
            COMMIT;
        END IF;
    END

 

转载于:https://www.cnblogs.com/Yiran583/p/7125455.html

你可能感兴趣的:(Mysql存储过程中的事务回滚)