CREATE PROCEDURE TransTest(in p1 VARCHAR(20),in p2 VARCHAR(50)) BEGIN declare err int default 0; /*如果出现sql异常,则将err设置为1后继续执行后面的操作 */ declare continue handler for sqlexception set err=1; -- 出错处理 set autocommit = 0; insert into sy_queryconfig(syq_id) values(p1); insert into sy_queryconfig(syq_id) values(p2); if err=1 then ROLLBACK; ELSE COMMIT; end if; END