Re: sql%notfound and NO_DATA_FOUND exceptions.
Date: 1996/11/28
Message-ID: <329DD850.2806_at_uk.sun.com>#1/1
Rashid Karimov wrote:
>
> In the code like the following:
>
> begin
> select id into t_id from widgets
> where name = 'X';
> if sql%notfound then
> null;
> end if;
>
> exception
> when *****
> **********
> end;
>
> Does the sql%notfound stmt. I have guarantees
> that NO_DATA_FOUND exception will not get propagated into
> exception block when and if raises ?
> What if I have if sql%found instead of sql%notfound , which
> looks like this:
>
> if sql%found then
> code1;
> else
> code2;
> end if;
>
> Will the NO_DATA_FOUND exception lead to the execution
> of code2 or I'll get an (explicit) exception ?
>
> And the other question I had stands not changed:
>
> in the code like:
>
> select id from t1
> where cond1
> UNION
> select id from t1
> where cond2;
>
> if it happens that one of the tables doesn't have any
> rows satisfying cond1 or cond2 , would I get NO DATA FOUND ?
>
> E-mail copy of followup , if any , would be appreciated.
> --
> ------------------
>
> Beyond the horizon of the place we lived when we were young
> In the world of magnets and miracles
> Our thoughts strayed constantly and without boundary
> The ringing of the division bell had begun ...
> -=PF, The Division Bell=-
Rashid
Your sql%notfound will be ignored completely. Control jumps straight to the exception handler, where you should test for NO_DATA_FOUND. The %NOTFOUND is really only useful for explicit cursors.
The UNION will only raise NO_DATA_FOUND if *both* queries return no rows.
A division bell is a bell that is rung in the British parliament and the surrounding pubs in order to inform the MPs that there is a vote. The MPs vote by "dividing" into 2 lines - for and against the motion.
Hope this helps...
JR
Received on Thu Nov 28 1996 - 00:00:00 CET