Re: functions are returns columns

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: functions are returns columns
Дата
Msg-id 874pftdd89.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: functions are returns columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: functions are returns columns
Список pgsql-sql
"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> Gregory Stark <stark@enterprisedb.com> writes:
>> You're almost there:
>
>> CREATE FUNCTION getfoo (IN int, OUT int, OUT int) returns setof record(int,int) AS $$
>>   SELECT fooid, foosubid FROM foo WHERE fooid = $1;
>> $$ LANGUAGE SQL;
>
> Not quite --- it's just "returns setof record".  The output column types
> are defined by the OUT parameters.  The only reason you need the returns
> clause is to have a place to stick the "setof" specification ...

ok...

I did test my example before posting it:

postgres=# postgres=# CREATE or replace FUNCTION getfoo (IN int, OUT int, OUT int) returns setof record(int,int)AS $$
SELECT1,2 union all select 2,3;
 
$$ LANGUAGE SQL;

postgres$# postgres$# CREATE FUNCTION
postgres=# postgres=# select * from getfoo(1);column1 | column2 
---------+---------      1 |       2      2 |       3
(2 rows)
--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: functions are returns columns
Следующее
От: Tom Lane
Дата:
Сообщение: Re: functions are returns columns