--你试试看
CREATE OR REPLACE procedure ll_04 is
begin
insert to table1 ....
IF SQL%ROWCOUNT = 0 --sql影响记录数
then
ROLLBACK;
end if;
insert to table2 ....
IF SQL%ROWCOUNT = 0 --sql影响记录数
then
ROLLBACK;
end if;
insert to table3 ....
IF SQL%ROWCOUNT = 0 --sql影响记录数
then
ROLLBACK;
end if;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
ROLLBACK;
end ll_04;
可能我没说明白吧,我是要实现类似sql server中这样的功能:
CREATE PROCEDURE xxxx
(xx
..
xx)
AS
BEGIN TRAN
insert to table1 ....
IF (@@ERROR <> 0)
begin
rollback tran
return -1
end
insert into table2 ...
IF (@@ERROR <> 0)
begin
rollback tran
return -1
end
INSERT ALL
INTO table_1 (id, name)
values(id,name)
INTO table_2 (id, name)
values(id,name)
INTO table_other (id, name)
values(id, name)
SELECT id,name
FROM a;