From: Thomas Pundt <mlists@rp-online.de>
To: Marc Mamin <M.Mamin@intershop.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: record to columns: syntax question and strange behaviour
Date: Tue, 27 Oct 2009 18:20:46 +0100
Message-ID: <4AE72BEE.5070801@rp-online.de> (raw)
In-Reply-To: <C4DAC901169B624F933534A26ED7DF31010A5364@JENMAIL01.ad.intershop.net>
References: <C4DAC901169B624F933534A26ED7DF31010A5364@JENMAIL01.ad.intershop.net>
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
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-sql@postgresql.org
Cc: mlists@rp-online.de, M.Mamin@intershop.de
Subject: Re: record to columns: syntax question and strange behaviour
In-Reply-To: <4AE72BEE.5070801@rp-online.de>
* 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