Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Exception inside function not being propagated to query
Brian,
Why would you want to return an invalid state via an exception ? why not just return 'Invalid' and use you exception handlers to handle exceptions ?
Chris.
bdg_at_hotmail.com wrote:
>
> I'm probably missing something simple here, but . . .
>
> I have a function with the definition
>
> FUNCTION test_function(p_value NUMBER) RETURN VARCHAR2 IS
> BEGIN
> IF p_value = 1 THEN
> RETURN 'Valid';
> ELSE
> RAISE NO_DATA_FOUND;
> END IF;
> END;
>
> When called from a query, the function doesn't seem to be propagating the
> exception as I would expect it to. For example . . .
>
> ********************************************************
>
> SQL> select test_function(1) from dual;
>
> TEST_FUNCTION(1)
> -----------------------------------------------------------------------------
> --- Valid
>
> SQL> select test_function(2) from dual;
>
> TEST_FUNCTION(2)
> -----------------------------------------------------------------------------
> ---
>
> SQL>
>
> ********************************************************
>
> The same results occur if the function is inside a package. I would prefer
> that the exception stop the query entirely. Any hints?
>
> Thanks,
> Brian Gastineau
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Wed Feb 10 1999 - 18:46:31 CST