Re: NO_DATA_FOUND EXCEPTION

From: Kevin J. Bourque <af788_at_cfn.cs.dal.ca>
Date: 1995/05/04
Message-ID: <D81zsE.FyM_at_cs.dal.ca>#1/1


JamesRichard wrote:
: In article <3nbutc$4sp_at_news.annex.com> sanctus2_at_annex.com () writes:
: >In PL/SQL, if I do a SELECT INTO or a FETCH that returns 0 records, the
: >NO_DATA_FOUND EXCEPTION is raised. That's all well and good but what do
: >I do with it? If I write code to only do something if I RETRIEVE
: >records, why can't I ignore the NO_DATA_FOUND? It ends up generating an
: >error in my trigger and rolls back my transaction.
: >
: >I want to be able to retrieve no records WITHOUT erroring out my trigger.
: >
: >I'd appreciate any help on this issue.
: >Thanx....
: >
: >Jack Schwartz
: >Systems Analyst
: >Great Western Bank
 

: How about doing
 

: SELECT COUNT (*) INTO COUNTER FROM TABLE
: FROM TABLE WHERE etc.
 

: first.
 

: IF COUNTER > 0 THEN process
: END IF;
 
: This will bypass the NO_DATA_FOUND Exception.
 

: James Richard (JRICHARD_at_TUNS.CA)
: "No Assembler Required!"

--
****************

You can also embed your select inside a BEGIN ... END, and provide an 
exception handler eg. 
BEGIN
  select ..
  into   ..
  from   ..
  where  ..;
WHEN NO_DATA_FOUND THEN 
  NULL;
END;

KJ Bourque  (kevin.bourque_at_nspower.ns.ca)

**************************
Received on Thu May 04 1995 - 00:00:00 CEST

Original text of this message