Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: testing variable state in functions
Possibly because when nothing is found to match the first Select the
exception is taken. Wrap a Begin/Exception/End around the Selects and you'll
probably get what you want.
"Isma" <Ismael_at_NOSPAMiballo.com> wrote in message
news:a1chh5$9m2$1_at_sunnews.cern.ch...
> HI,
>
> I've got a simple function which has a pb when I test the r_serial_n
> variable. It seems that ( see below ) (1)IF is not taken in account.
> It returns a blank result. If the statement reaches ELSE, it works ..
>
> It seems that NULL statement is not suitable here, but what else may I use
?
>
> Thanks
>
> CREATE OR REPLACE FUNCTION warr_date (f_serial_n VARCHAR2)
> RETURN DATE
> IS
> r_serial_n VARCHAR2(20) ;
> i_arrival DATE;
> BEGIN
> SELECT serial_n
> INTO r_serial_n
> FROM RMA_R
> WHERE serial_n = f_serial_n;
>
> SELECT arrival
> INTO i_arrival
> FROM INFOGLOB
> WHERE serial_n= f_serial_n;
>
> (1) IF r_serial_n IS NULL THEN
> RETURN(i_arrival);
> (2)ELSE
> RETURN(r_warr_date(f_serial_n));
> END IF;
>
> EXCEPTION
> WHEN NO_DATA_FOUND THEN RETURN(NULL);
> END;
> /
>
>
Received on Mon Jan 07 2002 - 18:12:37 CST
![]() |
![]() |