From: Gregory Stark <stark@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michele Petrazzo - Unipex srl <michele.petrazzo@unipex.it>
Cc: Pgsql-Sql <pgsql-sql@postgresql.org>
Subject: Re: functions are returns columns
Date: Sat, 10 Nov 2007 21:04:06 +0000
Message-ID: <874pftdd89.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <19335.1194723995@sss.pgh.pa.us>
References: <4734B921.5050704@unipex.it>
<162867790711091235i7e77abcch27731d91285949b6@mail.gmail.com>
<4735EC6F.5050908@unipex.it>
<878x55dhau.fsf@oxford.xeocode.com>
<19335.1194723995@sss.pgh.pa.us>
"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 $$
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: stark@enterprisedb.com, tgl@sss.pgh.pa.us, michele.petrazzo@unipex.it
Subject: Re: functions are returns columns
In-Reply-To: <874pftdd89.fsf@oxford.xeocode.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox