Search Postgresql Archives

plpgsql using EXECUTE function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I would like to have one function in plpgsql which is gen_func. From this function I would like to call other functions depending on
the input parameters of gen_func - lets say f1 and f2. Parameters to f1 or f2 are text, refcursor and text[].

I tried to use EXECUTE but the problem is how to get refcursor and text[] to sql string.

After quite some time I found that if you do 

DECLARE 
cur1 refcursor;
arr1 text[];
tmp text;
...
BEGIN
...
tmp = cur1; 
tmp = arr1;
END;

will get the name of the cursor to tmp or format arr1 to text representation or would quote text strings.

Then I could constructed the sql like
sql = 'SELECT ' || f1 || '(\'' || tmp .....
and then
EXECUTE sql;

Is this the right way?

Should I quote_ident function name f1 or f2?
Is it the supposed action of tmp=arr1 to quote_literal its values?

Thank you for zour replies.




---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux