Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to use user function in SELECT query
"Procrastinator" <ali711_at_sunnipath.com> wrote in message
news:1146650178.715782.263470_at_e56g2000cwe.googlegroups.com...
> This doesn't work
>
> Declare
>
> bignum number ;
>
> function sqr(n number) return number
> is
> begin
> return n * n ;
> end;
> begin
>
> -- dbms_output.put_line(sqr(3));
> select sqr(3) into bignum from dual;
>
> end;
>
Declare the function standalone or in a package and you will be able to call it from SQL. Local functions are not visible to the SQL engine and therefore can't be used in SQL statements, only PL/SQL block they are declared in can see them. Besides, your select is pointless, you can simply
bignum := sqr(3);
And please familiarize yourself with PL/SQL Developer's Guide and Reference before posting more such questions as it's all described there in great detail. Oracle manuals are available for free from Oracle Technology Network.
-- Vladimir M. Zakharychev N-Networks, makers of Dynamic PSP(tm) http://www.dynamicpsp.comReceived on Wed May 03 2006 - 05:31:44 CDT
![]() |
![]() |