Re: functions are returns columns - Mailing list pgsql-sql

From Gregory Stark
Subject Re: functions are returns columns
Date
Msg-id 878x55dhau.fsf@oxford.xeocode.com
Whole thread Raw
In response to Re: functions are returns columns  (Michele Petrazzo - Unipex srl <michele.petrazzo@unipex.it>)
Responses Re: functions are returns columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
"Michele Petrazzo - Unipex srl" <michele.petrazzo@unipex.it> writes:

> I try with:
> CREATE FUNCTION getfoo (IN int, OUT int, OUT int) AS $$
>    SELECT fooid, foosubid FROM foo WHERE fooid = $1;
> $$ LANGUAGE SQL;
>
> but only one row returned...

You're almost there:

CREATE FUNCTION getfoo (IN int, OUT int, OUT int) returns setof record(int,int) AS $$ SELECT fooid, foosubid FROM foo
WHEREfooid = $1;
 
$$ LANGUAGE SQL;

The return type if present has to match the OUT (and BOTH) parameters.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Get trained by Bruce Momjian - ask me about
EnterpriseDB'sPostgreSQL training!
 


pgsql-sql by date:

Previous
From: Michele Petrazzo - Unipex srl
Date:
Subject: Re: functions are returns columns
Next
From: Tom Lane
Date:
Subject: Re: functions are returns columns