From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Michele Petrazzo - Unipex srl" <michele(dot)petrazzo(at)unipex(dot)it>, "Pgsql-Sql" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: functions are returns columns |
Date: | 2007-11-10 21:04:06 |
Message-ID: | 874pftdd89.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Gregory Stark <stark(at)enterprisedb(dot)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 $$
SELECT 1,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!
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-10 23:14:50 | Re: functions are returns columns |
Previous Message | Tom Lane | 2007-11-10 19:46:35 | Re: functions are returns columns |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-11-10 23:14:50 | Re: functions are returns columns |
Previous Message | Tom Lane | 2007-11-10 19:46:35 | Re: functions are returns columns |