Re: NO_DATA_FOUND EXCEPTION

From: Craig L Hollister <Craig.Hollister_at_DaytonOH.ncr.com>
Date: 1995/04/26
Message-ID: <D7nIur.30r_at_intruder.daytonoh.attgis.com>#1/1


> In article <D7JMpG.MGD_at_lanier.com> Don Vick writes:
> In article <3nbutc$4sp_at_news.annex.com>, <sanctus2_at_annex.com> wrote:
> >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.
> >
>
> One approach would be to encapsulate the retrieval in a procedure. [...]
>

Or simply encapsulate the retrieval in a PL/SQL block. Something like:

BEGIN
    do stuff ...
    BEGIN

        SELECT INTO or FETCH or whatever ...
        do something with what was retreived ...
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
        NULL; /* do nothing if nothing retreived */     END;
    do more stuff whether or not data was found ... END; Received on Wed Apr 26 1995 - 00:00:00 CEST

Original text of this message