【发布时间】:2015-10-06 05:37:27
【问题描述】:
这个exceptions processing article 建议把
嵌套块内的EXCEPTIONS 子句。
当出现异常时,继续下一条记录。
它适用于OP。
但是,当我尝试这个时,我得到了 PLS-000103 Error。
这是我的代码:
问题
如何继续处理不属于异常的记录(A、C、E)?
set serveroutput on;
/* Goal is to process all records that don't cause exceptions.
Using guidance from
http://www.oracle.com/technetwork/issue-archive/2011/11-mar/o29plsql-085126.html
Desired results
===============
A
C
E
*/
declare
v_exception varchar2(1);
v_item_a varchar2(2);
v_item_b varchar2(1);
cursor c_list
is
(
select 'A' as item from dual union all
select 'BB' as item from dual union all
select 'C' as item from dual union all
select 'DD' as item from dual union all
select 'E' as item from dual union all
select 'FF' as item from dual);
begin
for items in c_list loop
v_item_b := items.item;
dbms_output.put_line(v_item_b);
/* Putting an excpetion block inside the for loop causes
PLS-00103: Encountered the symbol "EXCEPTION"
exception when others
then dbms_output.put_line('Msg 28:[' || SQLERRM || ']');
end;
*/
end loop;
/* Putting it here works.
*/
exception when others
then dbms_output.put_line('Exception OK here:[' || SQLERRM || ']');
end;
【问题讨论】:
标签: oracle plsql exception-handling oracle11g