Thi*_*ATR 6 sql plsql exception oracle11g
我有一组表名,比方说150。每个表都有一mail_id
列,现在我要mail_id
在所有表中搜索一个。为此,我编写了一个Plsql块。当我遍历一组表时,某些表不存在,因此引发了异常。我有异常处理块来处理该异常。现在我想循环整个表,即使它引发异常?任何的想法?实际上,我的块没有处理该特定异常!
declare
my_mail_id varchar2(50):='xyaksj@jsm.com';
tmp_table varchar2(125);
type varchar_collector is table of varchar2(255);
var varchar_collector;
table_does_not_exist exception;
PRAGMA EXCEPTION_INIT(table_does_not_exist, -00942);
begin
for cntr in (select table_name from user_tables)
loop
tmp_table:=cntr.table_name;
dbms_output.put_line(tmp_table);
for mail in (select email_address from tmp_table where lower(email_address) like '%my_mail_id%' )
loop
dbms_output.put_line(tmp_table);
end loop;
end loop;
exception
when no_data_found then
dbms_output.put_line('email address not found');
WHEN table_does_not_exist then
dbms_output.put_line('table dose not exists');
WHEN OTHERS THEN
--raise_application_error(-20101, 'Expecting at least 1000 tables');
IF (SQLCODE = -942) THEN
--DBMS_Output.Put_Line (SQLERRM);
DBMS_Output.Put_Line ('in exception');--this exception not handled
ELSE
RAISE;
END IF;
end;
Run Code Online (Sandbox Code Playgroud)
See*_*arp -1
try below code...
DECLARE
foo BOOLEAN;
BEGIN
FOR i IN 1..10 LOOP
IF foo THEN
GOTO end_loop;
END IF;
<<end_loop>> -- not allowed unless an executable statement follows
NULL; -- add NULL statement to avoid error
END LOOP; -- raises an error without the previous NULL
END;
Run Code Online (Sandbox Code Playgroud)