Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> where NO_DATA_FOUND exception
The following seems to act strange and tricky to me.
Say there's a function like this
create or replace function fu return varchar2 is
res varchar2(20);
begin
select 'u' into res from dual where dummy='Y';
return res;
end;
so
select fu() from dual;
and
declare
s varchar2(20);
begin
select fu() into s from dual;
end;
/
work with no exceptions whereas
declare
s varchar2(20);
begin
s:=fu();
end;
raises ORA-01403 (no data found) just like I expect in both cases.
Furthermore if we change our function this way
create or replace function fu return varchar2 is
res varchar2(20);
begin
select 'u' into res from dual where dummy='Y';
return res;
exception
when others then raise_application_error(-20001, 'user exception',
true);
end;
in this case (of course)
select fu() from dual;
and
declare
s varchar2(20);
begin
select fu() into s from dual;
end;
/
raise the exception
Would you explain what it is all about
Sincerely Michael Received on Fri Oct 25 2002 - 16:36:42 CDT