| 订阅 | 在线投稿
分享
 
 
 

MySQL存储过程SAVEPOINT ROLLBACK to

来源:互联网  宽屏版  评论
2008-06-01 02:56:55

本文为【MySQL存储过程SAVEPOINT ROLLBACK to】的汉字拼音对照版显示拼音

MySQLcunchuguochengSAVEPOINT ROLLBACK to

shiliruxia

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 ;

#ceshibiao

CREATE TABLE `eugene` (

t1` int(4) default NULL

)

原文
 
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 )
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有