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 -> Re: RAISED EXCEPTION not well caught

Re: RAISED EXCEPTION not well caught

From: Frank van Bortel <fvanbortel_at_netscape.net>
Date: Tue, 09 Mar 2004 18:47:16 +0100
Message-ID: <c2kvrj$7ee$1@news2.tilbu1.nb.home.nl>


Peter Wu wrote:

> Hello group,
>
> I'm new to Oracle PL/SQL.
>
> I have written a test script as follows.
>
> BEGIN
> select min(contract_start_date)
> into l_min_contract_start_date
> from contracts
> where customer_last_name = 'Bush';
>
> if (l_min_contract_start_date is null) then
> raise NO_DATA_FOUND;
> end if;
>
> BEGIN
>
> /* do something */
>
> EXCEPTION WHEN NO_DATA_FOUND THEN
> BEGIN
> /*
> do something to handle the exception within
> the nearest BEGIN
> */
>
> -- Exception Handler1
>
> END;
> END;
>
>
>
> EXCEPTION WHEN NO_DATA_FOUND THEN
> BEGIN
> /*
> do something to handle the excpetion raised by
> contract_start_date SELECT */
>
> -- Exception Handler2
>
> END;
> END;
> END;
>
>
> The problem I see is that when the NO_DATA_FOUND exception is raised
> after the SELECT, the program goes to Exception Handler1 instead of
> Exception Handler2 as I want it to.
>
> What was I missing? Any insight will be appreciated!
>
>

a raise statement. Like:
exception
when no_data_found then

   do_something, but not all; /* why not all? */    raise;
when others then
...
end;

Why don't you handle the error where it is raised anyway?

-- 

Regards,
Frank van Bortel
Received on Tue Mar 09 2004 - 11:47:16 CST

Original text of this message

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