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: PL/SQL: Dynamically calling a function., Need help

Re: PL/SQL: Dynamically calling a function., Need help

From: <Solomon.Yakobson_at_entex.com>
Date: 1997/04/16
Message-ID: <861223200.3525@dejanews.com>#1/1

I think all you need is a driver function:

CREATE FUNCTION RuleDriver(rule         IN     VARCHAR2,
                           an_object_id IN     NUMBER,
                           as_error_msg    OUT VARCHAR2)
                                                 RETURN NUMBER AS
BEGIN
    IF rule = 'RuleA' THEN
      RETURN RuleX(an_object_id,as_error_msg);     ELSIF rule = 'RuleB' THEN
      RETURN RuleX(an_object_id,as_error_msg);
    .
    .
    .
    ELSIF rule = 'RuleZ' THEN
      RETURN RuleX(an_object_id,as_error_msg);
    ELSE
      RAISE_APPLICATION_ERROR(-20001,'Invalid Function '||
                                     rule);
    END IF;
END;
/

Dynamic SQL will work too, but it would be slower.

Solomon.Yakobson_at_entex.com

In article <aj.26.000CF4D7_at_knoware.nl>,
  aj_at_knoware.nl (Allard Siemelink) wrote:
>
>
> Hi,
> We're currently working on a large project and need to call
> stored procedures and functions dynamically from PL/SQL.
> All functions have the same input and output parameters and
> return a number. e.g.:
>
> function ruleX (an_object_id in number,
> as_error_msg out varchar) return number
> begin
> --BODY
> end;
>
> Is it possible to call such a function dynamically? (Meaning
> retrieving the name of the function from a database column into
> a local varchar variable, compose the function call syntax
> 'execute ruleX(...)' in a varchar variabele and then call it)
> And if it is, could some kind soul provide an example showing
> how to call such a function, passing the input parameters and
> retrieving the output parameters and return value?
>
> TIA,
>
> -Allard

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
Received on Wed Apr 16 1997 - 00:00:00 CDT

Original text of this message

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