On 10/9/06, Michael Fuhr <mike@xxxxxxxx> wrote:
On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote: > I try EXECUTE f || ' ( ' || p || ' );' INTO res > But is does not work too. > There is no function to convert double precision[] to text. You could use the types' input and output functions or perhaps array_to_string(). stmt := 'SELECT ' || quote_ident(f) || '(' || quote_literal(textin(array_out(p))) || ')'; EXECUTE stmt INTO res;
thinking about this some more, it looks like the basic issue is passing in function to operate over a defined type, sort of like a sql closure. This can be rigged in dynamic sql but this has couple problems. Complex types are a pain (record types are even worse) and dynamic sql feels like a kludge anyhow. Here is maybe another solution: you can make a make an oid from a string: esilo=# create function foo() returns void as $$ ; $$ language sql; CREATE FUNCTION esilo=# select 'foo()'::regprocedure::oid; oid -------- 300009 (1 row) whierle the is no way to call a function via its oid in pl/pgsql, it is fairly trivial from C and somewhat generic using OidFunctionCall1(): (or 2, etc) http://www.nabble.com/improvise-callbacks-in-plpgsql-tf476925.html#a1299810 I have tested this approach, and it works! merlin