Passing a table as parameter

Поиск
Список
Период
Сортировка
От Jon Smark
Тема Passing a table as parameter
Дата
Msg-id 346859.41485.qm@web112809.mail.gq1.yahoo.com
обсуждение исходный текст
Ответы Re: Passing a table as parameter  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: Passing a table as parameter  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
Список pgsql-general
Hi,

Is there any way for a SQL or PL/pgSQL function to receive a table
as parameter?  As an illustration, consider the dummy example below.
Note that functions get_from_data1 and get_from_data2 follow essentially
the same pattern; it would be nice to define instead a single polymorphic
function parameterised on the id and table.  Is this possible?

Thanks in advance!
Jon


CREATE TABLE data1 (id int4, content text);
CREATE TABLE data2 (id int8, content text);


CREATE FUNCTION get_from_data1 (int4)
RETURNS SETOF text
LANGUAGE sql STABLE AS
$$
        SELECT content FROM data1 WHERE id = $1;
$$;


CREATE FUNCTION get_from_data2 (int8)
RETURNS SETOF text
LANGUAGE sql STABLE AS
$$
        SELECT content FROM data2 WHERE id = $1;
$$;





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

Предыдущее
От: tv@fuzzy.cz
Дата:
Сообщение: Re: query taking much longer since Postgres 8.4 upgrade
Следующее
От: Aljoša Mohorović
Дата:
Сообщение: postgres conferences missing videos?