Skip site navigation (1) Skip section navigation (2)

Re: Stored Procedure

From: Yves Vindevogel <yves(dot)vindevogel(at)implements(dot)be>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Stored Procedure
Date: 2005-11-22 22:20:09
Message-ID: 06612338d301f531643d479a819e4632@implements.be (view raw or flat)
Thread:
Lists: pgsql-performance
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


Attachment: Pasted Graphic 2.tiff
Description: image/tiff (5.6 KB)

In response to

Responses

pgsql-performance by date

Next:From: Anjan DaveDate: 2005-11-22 23:17:27
Subject: Re: High context switches occurring
Previous:From: Yves VindevogelDate: 2005-11-22 22:17:41
Subject: Re: Stored Procedure

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group