From: Michael Fuhr <mike@fuhr.org>
To: Yves Vindevogel <yves.vindevogel@implements.be>
Cc: pgsql-performance@postgresql.org
Subject: Re: Stored Procedure
Date: Tue, 22 Nov 2005 11:59:42 -0700
Message-ID: <20051122185941.GA18102@winnie.fuhr.org> (raw)
In-Reply-To: <e28aace15975ef9972fdd65ceb6e0ce8@implements.be>
References: <e28aace15975ef9972fdd65ceb6e0ce8@implements.be>
On Tue, Nov 22, 2005 at 07:29:37PM +0100, Yves Vindevogel wrote:
> Is there another way in PG to return a recordset from a function than
> to declare a type first ?
In 8.1 some languages support OUT and INOUT parameters.
CREATE FUNCTION foo(IN x integer, INOUT y integer, OUT z integer) AS $$
BEGIN
y := y * 10;
z := x * 10;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;
SELECT * FROM foo(1, 2);
y | z
----+----
20 | 10
(1 row)
CREATE FUNCTION fooset(IN x integer, INOUT y integer, OUT z integer)
RETURNS SETOF record AS $$
BEGIN
y := y * 10;
z := x * 10;
RETURN NEXT;
y := y + 1;
z := z + 1;
RETURN NEXT;
END;
$$ LANGUAGE plpgsql IMMUTABLE STRICT;
SELECT * FROM fooset(1, 2);
y | z
----+----
20 | 10
21 | 11
(2 rows)
--
Michael Fuhr
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-performance@postgresql.org
Cc: mike@fuhr.org, yves.vindevogel@implements.be
Subject: Re: Stored Procedure
In-Reply-To: <20051122185941.GA18102@winnie.fuhr.org>
* 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