Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to use user function in SELECT query

Re: How to use user function in SELECT query

From: Vladimir M. Zakharychev <bob--nospam--_at_dynamicpsp.com>
Date: Wed, 3 May 2006 14:31:44 +0400
Message-ID: <e3a0qh$2s0m$1@hypnos.nordnet.ru>

"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.com 
Received on Wed May 03 2006 - 05:31:44 CDT

Original text of this message

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