plpgsql using EXECUTE function

Поиск
Список
Период
Сортировка
От Damjan Pipan
Тема plpgsql using EXECUTE function
Дата
Msg-id 20051110115941.76572362581@gw.xlab.si
обсуждение исходный текст
Список pgsql-general
Hi,

I would like to have one function in plpgsql which is gen_func. From this function I would like to call other functions
dependingon 
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.




В списке pgsql-general по дате отправления:

Предыдущее
От: "Helge Elvik"
Дата:
Сообщение: Compiling libpq on Windows
Следующее
От: juleni@livetrade.cz
Дата:
Сообщение: TIMESTAMP vs TIMESTAMP WITHOUT TIME ZONE