DROP PROCEDURE IF EXISTS pro_rep_shadow_rs;create procedure pro_rep_shadow_rs(out rtn int)
begin
-- 如果出现异常,会自动处理并rollback
declare exit handler for sqlexception ROLLBACK ;
-- 启动事务
start transaction;
insert into test_user values(NULL,1,'啊是大三的');
insert into test_user VALUES(NULL,23,'sdsd',ss); --故意写错的
-- 运行没有异常,提交事务
commit;
-- 设置返回值为1
set rtn=1;
end; 最终还是使用存储过程来执行事务,要方便的多
begin
-- 如果出现异常,会自动处理并rollback
declare exit handler for sqlexception ROLLBACK ;
-- 启动事务
start transaction;
insert into test_user values(NULL,1,'啊是大三的');
insert into test_user VALUES(NULL,23,'sdsd',ss); --故意写错的
-- 运行没有异常,提交事务
commit;
-- 设置返回值为1
set rtn=1;
end; 最终还是使用存储过程来执行事务,要方便的多
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货