Re: record to columns: syntax question and strange behaviour

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: <thomas(dot)pundt(at)rp-online(dot)de>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: record to columns: syntax question and strange behaviour
Date: 2009-10-27 18:46:50
Message-ID: C4DAC901169B624F933534A26ED7DF311F9CD2@JENMAIL01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hello,

Your proposal unfortunately does not work if you try to query more than one value and want additional columns in the results,
like in

select column1,test(column1) FROM (values(1),(2)) foo

cheers,

Marc Mamin

>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);

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bryce Nesbitt 2009-10-28 18:44:30 pg_restore "WARNING: errors ignored on restore"
Previous Message Thomas Pundt 2009-10-27 17:20:46 Re: record to columns: syntax question and strange behaviour