From: Yves Vindevogel <yves.vindevogel@implements.be>
To: pgsql-performance@postgresql.org
Subject: Re: Stored Procedure
Date: Tue, 22 Nov 2005 23:20:09 +0100
Message-ID: <06612338d301f531643d479a819e4632@implements.be> (raw)
In-Reply-To: <20051122185941.GA18102@winnie.fuhr.org>
References: <e28aace15975ef9972fdd65ceb6e0ce8@implements.be>
<20051122185941.GA18102@winnie.fuhr.org>
8.1, hmm, that's brand new.
But, still, it's quite some coding for a complete recordset, not ?
On 22 Nov 2005, at 19:59, Michael Fuhr wrote:
> 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
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>
Met vriendelijke groeten,
Bien à vous,
Kind regards,
Yves Vindevogel
Implements
Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91
Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76
Web: http://www.implements.be
First they ignore you. Then they laugh at you. Then they fight you.
Then you win.
Mahatma Ghandi.
Attachments:Pasted Graphic 2.tiff (image/tiff, 5.6K) downloadview image
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: yves.vindevogel@implements.be
Subject: Re: Stored Procedure
In-Reply-To: <06612338d301f531643d479a819e4632@implements.be>
References: <e28aace15975ef9972fdd65ceb6e0ce8@implements.be> <20051122185941.GA18102@winnie.fuhr.org> <06612338d301f531643d479a819e4632@implements.be>
* 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