MySQL存储过程SAVEPOINT ROLLBACK to
MySQL存储过程SAVEPOINT ROLLBACK to
示例如下: DELIMITER $
DROP PROCEDURE IF EXISTS `test`.`handlerdemo`$
CREATE DEFINER=`root`@`localhost` PROCEDURE `handlerdemo`() BEGIN DECLARE X2 INT; DECLARE CONTINUE HANDLER FOR SQLWARNING SET X2= 1; DECLARE CONTINUE HANDLER FOR NOT FOUND SET X2 = 2; DECLARE CONTINUE HANDLER FOR SQLSTATE ''23000'' SET X2= 3; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET X2 = 4; START TRANSACTION; SAVEPOINT savepoint_1; BEGIN INSERT INTO eugene VALUES (1); INSERT INTO eugene VALUES (2); SELECT X2; end; ROLLBACK TO SAVEPOINT savepoint_1; iNSERT INTO eugene VALUES (3); END$
DELIMITER ;
#测试表 CREATE TABLE `eugene` ( t1` int(4) default NULL ) |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |