使用异常处理好了 begin .... select date into aaa from table1; EXCEPTION then end;
不是在游标中提不出数来,是在过程中!!下面是部分代码:有省略 cursor init is select userid from input; open init; loop fetch init into lluserid; exit when init%notfound; select tb1.copydate into oldcopydate1 from (select row_number()over(order by year desc,usemonth desc) rn,copydate,real from history where userid=lluserid ) tb1 where rn=1; 是这个选择出来的东西没找到(tb1.copydate) 如何处理?
cursor init is select userid from input; open init; loop fetch init into lluserid; exit when init%notfound;begin select tb1.copydate into oldcopydate1 from (select row_number()over(order by year desc,usemonth desc) rn,copydate,real from history where userid=lluserid ) tb1 where rn=1;exception when no_data_found then null; when others then db_output.put_line(sql_code); end;end loop
begin
....
select date into aaa from table1;
EXCEPTION then
end;
cursor init is select userid from input;
open init;
loop
fetch init into lluserid;
exit when init%notfound;
select tb1.copydate
into oldcopydate1
from (select row_number()over(order by year desc,usemonth desc) rn,copydate,real from history where userid=lluserid ) tb1
where rn=1;
是这个选择出来的东西没找到(tb1.copydate)
如何处理?
open init;
loop
fetch init into lluserid;
exit when init%notfound;begin
select tb1.copydate
into oldcopydate1
from (select row_number()over(order by year desc,usemonth desc) rn,copydate,real from history where userid=lluserid ) tb1
where rn=1;exception
when no_data_found then
null;
when others then
db_output.put_line(sql_code);
end;end loop