dynamic functions in plpgsql - Mailing list pgsql-novice

From Tyler Bye
Subject dynamic functions in plpgsql
Date
Msg-id 6987538FE5E0D3119F1B0050DA7350D143816D@MERCURY
Whole thread Raw
List pgsql-novice
I'm currently trying to write a function that will query a table containing
the names of additional functions and then execute one of those functions
after selecting it from the table.

For example.

Say I have a (partial) function pick_fruit(varchar(20),varchar(20))
    type_of_fruit ALIAS FOR $1;
    employee ALIAS FOR $2;
    temprec RECORD;
...

If I SELECT pick_fruit('apple');I would like this function to take the
argument apple and query my pick_fruit_functions table for the  function
named pick_fruit_apple, then execute that function.

let's say that my column name for that list of functions is funcname.

I've tried selecting the function into a RECORD as temprec.  Then I
attempted to reference the result like so,

SELECT temprec.funcname(employee);
...

Is this type of dynamic function binding possible using plpgsql?

I hope this message wasn't too cryptic.

Thanks,
Tyler Bye



pgsql-novice by date:

Previous
From: ERIC Lawson - x52010
Date:
Subject: Re: PL/PGSQL syntax manual
Next
From: Tony Bazeley
Date:
Subject: Quick test for JDBC drivers