CREATE PROCEDURE `test`(
IN id int(10)
)
BEGIN
DECLARE t_error INTEGER DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1;
START TRANSACTION;
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,type) values('a','b',0);
insert into bbs(title, context,typedd) values('a','b',0);
IF t_error = 1 THEN
ROLLBACK;
ELSE
COMMIT;
END IF;
select t_error;
END
网友评论