dynamic functions in plpgsql

From: Tyler Bye <tyler(dot)bye(at)worldwidepackets(dot)com>
To: "'pgsql-novice(at)hub(dot)org'" <pgsql-novice(at)hub(dot)org>
Subject: dynamic functions in plpgsql
Date: 2000-09-14 23:55:49
Message-ID: 6987538FE5E0D3119F1B0050DA7350D143816D@MERCURY
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-novice by date

  From Date Subject
Next Message Tony Bazeley 2000-09-15 06:04:06 Quick test for JDBC drivers
Previous Message ERIC Lawson - x52010 2000-09-14 23:07:27 Re: PL/PGSQL syntax manual