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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Function

Re: Function

From: Stefan Jahnke <stefan.jahnke_at_d2vodafone.de>
Date: Wed, 24 Oct 2001 07:08:46 -0700
Message-ID: <F001.003B30DB.20011024065131@fatcity.com>

Hi,

I guess what you want is more heading towards dynamic sql:

Start with a PL/SQL block like this:

DECLARE
  v_funcName VARCHAR2(50);
  v_statement VARCHAR2(255);

BEGIN
  SELECT function_name INTO v_funcName

     FROM function
   WHERE function_name;
  v_statement := 'SELECT ' || v_funcName || ' FROM DUAL';

   ....then, execute the statement, bind the column to a variable ... finito.

END; cheers,
Stefan

"Mercadante, Thomas F" schrieb:

> Dpb,
>
> within PL/SQL you can:
>
> -- declare a variable to store the result from the function
>
> func_res number;
>
> -- within the PL/SQL block, call the function and store the result:
>
> func_res := calc_radius(5);
>
> -- or, you can
> select calc_radius(5) into func_res from dual;
>
> You do NOT need to use the execute immediate command.
>
> Hope this helps
>
> Tom Mercadante
> Oracle Certified Professional
>
> -----Original Message-----
> [mailto:Divya_pb/VGIL_at_vguard.satyam.net.in]
> Sent: Wednesday, October 24, 2001 2:20 AM
> To: Multiple recipients of list ORACLE-L
>
> Hi All
>
> I have stored a user defined function as Varchar field in a table.
> How do I execute this function.
>
> Here is the table where the function is stored.
>
> SQL> select * from func;
>
> FUNCTION_NAME
> -----------------------------------------
> Calc_radius(5)
>
> This procedure contains the following Code :
>
> create function calc_radius(r in number) return number is
> begin
> return 3.14*r*r;
> end;
>
> Executing this funtion at SQL Prompt give the output as
>
> SQL> SELECT CALC_RADIUS(5) FROM DUAL;
>
> CALC_RADIUS(5)
> --------------
> 78.5
>
> I want to execute this function from a PL/SQL Block.
> I tried to store this function into a variable and then execute it.
> But it returns only the content of the field FUNCTION_NAME
> and not the value.
>
> Can anyone suggest a solution for this problem ?
>
> Regards
> Dpb
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author:
> INET: Divya_pb/VGIL_at_vguard.satyam.net.in
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Mercadante, Thomas F
> INET: NDATFM_at_labor.state.ny.us
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
> ---------------------------------------------------------
> This Mail has been checked for Viruses
> Attention: Encrypted mails can NOT be checked!
>
> **
>
> Diese Mail wurde auf Viren geprueft
> Hinweis: Verschluesselte mails koennen NICHT auf Viren geprueft werden!
> ---------------------------------------------------------

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Stefan Jahnke
  INET: stefan.jahnke_at_d2vodafone.de

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Oct 24 2001 - 09:08:46 CDT

Original text of this message

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