我一个触发器中很多个select into 语句,我想在每一个select into语句后面跟一个 exception when no_data_found then 来去除没有记录的情况。但是当我写了两个 select account_mon,bill_type into lsmon,lstype from flow_bill_m where bill_No = :new.bill_no and rownum = 1;
exception when no_data_found then
null;
select mod_date into closedate from bill_ctl where monthly = lsmon ;
exception when no_data_found then
null;
就出现错误pls-00103错误,发现附后exception当你等待下一个事件时:begin case declare and exit for goto if loop mod null pragma raise return select update when while with <ID>请教大家纠结了好久啊
exception when no_data_found then
null;
select mod_date into closedate from bill_ctl where monthly = lsmon ;
exception when no_data_found then
null;
就出现错误pls-00103错误,发现附后exception当你等待下一个事件时:begin case declare and exit for goto if loop mod null pragma raise return select update when while with <ID>请教大家纠结了好久啊
SQL> truncate table t_test_dml;
Table truncated
SQL> set serveroutput on
SQL>
SQL> declare
2 v_num number;
3 begin
4 select id into v_num from t_test_dml;
5 exception
6 when no_data_found then
7 begin
8 dbms_output.put_line('first');
9 select id into v_num from t_test_dml;
10 exception
11 when no_data_found then
12 dbms_output.put_line('second');
13 end;
14 end;
15 /
first
second
PL/SQL procedure successfully completed
SQL>
declarebeginexceptionend;
嵌套只能在块级进行.
直接在exception里再次exception是不成的
按照上面再嵌套就是了.
或者
你可以先select count(*)判断下是否有数据,然后做if else嵌套.不过怀疑的逻辑有问题.详细描述下?