Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 597C16327E0 for ; Tue, 27 Oct 2009 14:20:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 51471-06 for ; Tue, 27 Oct 2009 17:20:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.rp-online.de (mail.rp-online.de [149.221.1.199]) by mail.postgresql.org (Postfix) with ESMTP id C7D1763363E for ; Tue, 27 Oct 2009 14:20:48 -0300 (ADT) Received: from [10.1.19.116] (vpn17.1.rp-online.de [10.1.19.116]) by mail.rp-online.de (Postfix) with ESMTP id 2ED3E30928; Tue, 27 Oct 2009 18:20:47 +0100 (CET) Message-ID: <4AE72BEE.5070801@rp-online.de> Date: Tue, 27 Oct 2009 18:20:46 +0100 From: Thomas Pundt Reply-To: thomas.pundt@rp-online.de User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Marc Mamin CC: pgsql-sql@postgresql.org Subject: Re: record to columns: syntax question and strange behaviour References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.10/RELEASE, bases: 27102009 #2857262, status: clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/131 X-Sequence-Number: 33330 Hi, Marc Mamin schrieb: > how should I retrieve the result from a function with some OUT > paramenters? > > (PG is 8.3.7) > > here a short example to illustrate my question: > > CREATE OR REPLACE FUNCTION test (In a int, OUT b int, OUT c int) AS > $BODY$ > BEGIN > b:=a+1; > c:=a+2; > raise notice 'done: %', a; > END > > $BODY$ > LANGUAGE 'plpgsql' IMMUTABLE IMO easiest would be to include a RETURNS SETOF record in the function declaration and a return next; statement in the function body. E.g. CREATE OR REPLACE FUNCTION test (In a int, OUT b int, OUT c int) RETURNS SETOF record AS $BODY$ BEGIN b:=a+1; c:=a+2; return next; END $BODY$ LANGUAGE 'plpgsql' and then issue SELECT * FROM test(1); Ciao, Thomas