Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> where NO_DATA_FOUND exception

where NO_DATA_FOUND exception

From: Michael Maramzin <mvm_at_e-mail.ru>
Date: Fri, 25 Oct 2002 14:36:42 -0700
Message-ID: <3DB9B96A.4030600@e-mail.ru>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US