On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote: > I want to create a function in PL/SQL as > CREATE OR REPLACE FUNCTION "f_do" (text, double precision[]) RETURNS > double precision AS ' > DECLARE > f text := $1; > p double precision[] := $2; > res double precision; > BEGIN > SELECT f(p) into res; > RETURN res; > END;' LANGUAGE "plpgsql" > STABLE > RETURNS NULL ON NULL INPUT > SECURITY INVOKER > > But it does not work. > I try EXECUTE f || ' ( ' || p || ' );' INTO res > But is does not work too. > There is no function to convert double precision[] to text. > > Is it possible to do this without converting the array of double to > text ? Here's one (WARNING! UNTESTED!) thing you might try. CREATE OR REPLACE FUNCTION f_do (f text, p double precision[]) RETURNS double precision LANGUAGE plpgsql AS $$ DECLARE res double precision; BEGIN CREATE FUNCTION f_do_inner (inner_p double precision[]) /* Do not attempt to replace */ RETURNS double precision LANGUAGE plpgsql AS $q$ BEGIN RETURN $q$ || quote_ident(f) || $q$(inner_p); END; $q$; SELECT INTO ret f_do_inner(p); DROP FUNCTION f_do_inner(inner_p double precision[]); RETURN ret; END; $$; Cheers, David. -- David Fetter <david@xxxxxxxxxx> http://fetter.org/ phone: +1 415 235 3778 AIM: dfetter666 Skype: davidfetter Remember to vote!