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

Home -> Community -> Usenet -> c.d.o.misc -> Re: NO_DATA_FOUND exception workaround in functions?

Re: NO_DATA_FOUND exception workaround in functions?

From: Norris <johnnie_at_cooper.com.hk>
Date: 16 Sep 1999 07:50:05 GMT
Message-ID: <7rq7fd$2ivk$1@adenine.netfront.net>


Or you could use:

select 	min(emp_name) 
into 	v_emp_name 
from 	emp 
where 	emp_no = v_emp_no;

to force the DB return at least one row and then check for null

if v_emp_name is null then

michael_bialik_at_my-deja.com wrote:
> Hi.

> Use cursor instead of single select :

> declare
> cursor emp_crs ( pi number ) is
> select * from emp where emp_id = pi;
> begin
> open emp_crs(121212);
> fetch emp_crs into emp_rec;
> if emp_crs%notfound then
> ...
> end if;
> close emp_crs;
> end;

> Michael.

> In article <7rohsh$lh7$1_at_nnrp1.deja.com>,
> adil_at_msil.sps.mot.com wrote:

>> Hello,
>>
>> I have a function which, among other things, performs a query.  This
>> query sometimes returns no data (depending on the given arguments).
>> Apparently, when this happens, a "NO_DATA_FOUND" exception is quietly
>> thrown, and the function abruptly ends at this point.  I'd rather this
>> didn't happen, because I wish to continue even if the query returns no
>> data.  I could wrap each such query with in its own block, so that I
>> could catch the exception right after the query, but that would be

> very
>> cumbersome and could complicate my code significantly.  I could also
>> precede each select with another select to bring back the number of

> rows
>> the upcoming select will produce, but that's even more cumbersome.
>>
>> Does anyone have a more elegant solution to this problem?
>>
>> Thanks,
>>
>> Adi.
>>
>> Sent via Deja.com http://www.deja.com/

>> Share what you know. Learn what you don't.
>>


> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

-- 
- Have several nice days...
- Opinions are mine and do not necessarily reflect those of the Corp.
http://www.ntfaq.com
http://www.cyberport.com/~tangent/programming/winsock/ Received on Thu Sep 16 1999 - 02:50:05 CDT

Original text of this message

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