mysql & oracle savepoint 使用方法

season0891發表於2009-07-17
oracle savepoint:
begin
savepoint a;
insert into ages values(1,'age');
insert into ages values(1,'age');
insert into ages values(1,'age');
insert into ages values(1,'age11111111111111111111111111');
exception when others then
  begin
    rollback to a;
  end ;
commit;
end ;

mysql savepoint :

start transaction;
savepoint a;
insert into t set id =10;
insert into t set id =21;
insert into t set id =31;
rollback to savepoint a;


start transaction;
set @b=0;
declare continue handler for SQLEXCEPTION set @b=1;
savepoint a;
insert into t set id =10;
insert into t set id =21;
insert into tt set id =31;
if @b=1 then
rollback to savepoint a;
end if;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/90618/viewspace-609493/,如需轉載,請註明出處,否則將追究法律責任。

相關文章