Re: Passing a list of values to a function

Поиск
Список
Период
Сортировка
От Matthew Peter
Тема Re: Passing a list of values to a function
Дата
Msg-id 20060110041051.26971.qmail@web35215.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: Passing a list of values to a function  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
You could write the function to take an array of integers instead
of a text string:

CREATE OR REPLACE FUNCTION getlist(integer[]) RETURNS SETOF my_tbl as $$
SELECT * FROM my_tbl
WHERE u_id = 0 OR u_id = ANY($1)
$$ LANGUAGE SQL STABLE STRICT;

SELECT * FROM getlist('{1,2,3}');

Another way would be to build a query string in a PL/pgSQL function
and use EXECUTE, but beware of embedding function arguments in query
strings without quoting.

--
Michael Fuhr
Hmmmmmm .... I suspected it was using it as a text string, seeing how that's how it way defined. I guess querying it as an array would work okay.

Is there any way to blow out how the query was executed? Such as seeing all the WHERE joins and what not along with the explain output on the console? I think I read so mewhere about it showing in the logs or something?


Yahoo! Photos – Showcase holiday pictures in hardcover
Photo Books. You design it and we’ll bind it!

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

Предыдущее
От: Matthew Peter
Дата:
Сообщение: Re: plpgsql question
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: Vacuum all tables unders under one schema (not under one database)