1 CREATE PROCEDURE test_sp1( ) 2 BEGIN 3 DECLARE t_error INTEGER DEFAULT 0; 4 DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET t_error=1; 5 6 START TRANSACTION; 7 INSERT INTO test VALUES(NULL, ‘test sql 001‘); 8 INSERT INTO test VALUES(‘1‘, ‘test sql 002‘); 9 10 IF t_error = 1 THEN 11 ROLLBACK; 12 ELSE 13 COMMIT; 14 END IF; 15 16 END
原文:http://www.cnblogs.com/gaobing/p/3873694.html