begin
insert into table1;
begin
insert into table2;
execption
when others then
dbms_outupt.put_line('2');
end;
execption
when others then
dbms_outupt.put_line('1');
end;
insert into table1;
begin
insert into table2;
execption
when others then
dbms_outupt.put_line('2');
end;
execption
when others then
dbms_outupt.put_line('1');
end;
exception t_1;
exception t_2;
begin
insert ...
commit;
if sqlcode<>0 then
raise t_1;
end if;
inset .....
if sqlcode<>0 then
raise t_2;
end if;
exception
if t_1 then
--t1插入失败
end if;
if ...
....
when others then
...
end;
V_FLAG VARCHAR2(1) := '1';
begin
V_FLAG := '1';
INSERT TABLE1 .... ;
V_FLAG := '2';
INSERT TABLE2 ....;
exception
WHEN OTHERS THEN
IF V_FLAG = '1' THEN ELSIF V_FLAG = '1' THEN END IF;
end;
如果我一个PROCEDURE里面有10个或者20个SQL,
SELECT COL1 INTO VAR_1 tab1 where...
SELECT COL2 INTO VAR_2 tab2 where...
SELECT COL3 INTO VAR_3 tab3 where...
....
SELECT COL10 INTO VAR_10 tab10 where...不管前面是否有异常都一直执行下去那不是要写10 个,20
execption
when others then
NULL
end;哪程序岂不是太臃肿了,也太难看了,有没有办法使发生异常后不理会,一直往执行完,等待高手教我一招!!谢谢
SELECT COL1 INTO VAR_1 tab1 where...
SQL%ROWCOUNT因为SELECT COL1 INTO VAR_1 tab1 where...没有找到数据行 的时候,就已经引发了一个
异常,程序此时不会继续执行下面的语句,要么跳转到异常处理器,如果没有相应的异常处理代码,程序会直接停止了,SQL%ROWCOUNT不会被执行到,没有ORACLE高手帮忙码