Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Newbie Question
On Fri, 10 Sep 1999 23:33:47 GMT, khs_at_netset.com wrote:
>I have a SELECT statement that returns, at most, 1 row in a procedure.
>When the select doesn't return a row (NO_DATA_FOUND) I want to set the
>variable that recieves the column value to a space (' ') and go on
>with the rest of the logic in the procedure. What happens is that the
>procedure exits. How can I prevent this?
>
>Thanks for your help...
You have to trap the NO_DATA_FOUND exception in an exception handler. Once safely trapped, your code can continue without exiting.
Here's an example for you :
procedure MyProc(MyParameter in integer, AnOutput out integer)
is
MyVariable Char(1);
begin
begin
select
MY_CHAR_FIELD
into
MyVariable
from
MY_TABLE
where
MY_PRIMARY_KEY = MyParameter;
exception
when NO_DATA_FOUND then MyVariable := ' ';
Hope this helps.
Paul Scott Received on Fri Sep 10 1999 - 19:47:36 CDT
![]() |
![]() |