44.15. 针对Oracle的增强功能

  1. 函数功能增强:支持回滚和提交。

create table table_func_rbk(a int, b int);
insert into table_func_rbk values(100,100);
insert into table_func_rbk values(200,200);
select * from table_func_rbk order by a;
 
create or replace function func_rollback1(a int) return int
is 
begin
	insert into table_func_rbk values(300,300);
	commit;
	insert into table_func_rbk values(400,400);
	rollback;
	update table_func_rbk set a = 400 where a = 300;
	rollback;
	delete from table_func_rbk where a = 100;
	rollback;
	return a;
end;
/
select func_rollback1(100);
select * from table_func_rbk order by a;
 
create or replace function func_rollback1(a int) return int
is 
begin
	insert into table_func_rbk values('asdasda');
exception
	when others then
		insert into table_func_rbk values(300,300);
		commit;
		insert into table_func_rbk values(400,400);
		rollback;
		update table_func_rbk set a = 400 where a = 300;
		rollback;
		delete from table_func_rbk where a = 100;
		rollback;
		return a;
end;
/
select func_rollback1(100);
select * from table_func_rbk order by a;
 
drop table table_func_rbk;
drop function func_rollback1;