X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D71DDDB0D0 for ; Tue, 22 Nov 2005 14:59:51 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97373-09 for ; Tue, 22 Nov 2005 18:59:51 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 08C14DB0C8 for ; Tue, 22 Nov 2005 14:59:48 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id jAMIxgBl056556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 22 Nov 2005 11:59:45 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.4/8.13.4) with ESMTP id jAMIxgsQ018202; Tue, 22 Nov 2005 11:59:42 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.4/8.13.4/Submit) id jAMIxgfL018201; Tue, 22 Nov 2005 11:59:42 -0700 (MST) (envelope-from mfuhr) Date: Tue, 22 Nov 2005 11:59:42 -0700 From: Michael Fuhr To: Yves Vindevogel Cc: pgsql-performance@postgresql.org Subject: Re: Stored Procedure Message-ID: <20051122185941.GA18102@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000, UPPERCASE_25_50=0] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/452 X-Sequence-Number: 15709 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