Re: stored procedure: RETURNS record - Mailing list pgsql-general

From Merlin Moncure
Subject Re: stored procedure: RETURNS record
Date
Msg-id b42b73150909251727i3d9ed6b2j562133fe5bab1a0d@mail.gmail.com
Whole thread Raw
In response to Re: stored procedure: RETURNS record  (Rob Marjot <rob@marjot-multisoft.com>)
Responses Re: stored procedure: RETURNS record  (InterRob <rob.marjot@gmail.com>)
Re: stored procedure: RETURNS record  (Rob Marjot <rob@marjot-multisoft.com>)
List pgsql-general
On Fri, Sep 25, 2009 at 2:40 PM, Rob Marjot <rob@marjot-multisoft.com> wrote:
> Still no luck... To clarify a bit, take this example:
> CREATE OR REPLACE FUNCTION transpose()
>   RETURNS record AS
> $BODY$ DECLARE
>    output RECORD;
>  BEGIN
>    SELECT * INTO output FROM (VALUES(1,2)) as tbl(first,second);
>    RETURN output;
>  END;$BODY$
>   LANGUAGE 'plpgsql' STABLE
>   COST 100;
> Now, I expect to have 2 columns; named "first" and "second". However, like
> posted before, the flowing query:
> SELECT * FROM deserialize();
> produces only ONE column (in one row, as one would clearly expect from the
> function's defnition):
>  deserialize
> -----------
>  (1,2)
> (1 row)
>
> Any thoughts on how to make sure multiple columns are returned; without
> specifying this in the function's prototype return clause?

In a sense, what you are asking is impossible. Having a function (even
a C one) return 'record' does not get you out of having to define the
output columns...either in the function definition with 'out' or as
part of the calling query.  Depending on what you are trying to do,
this could either matter a little or a lot.  If it matters, why don't
you post some more details of the context of your problem and see if a
better solution can be found?

merlin

pgsql-general by date:

Previous
From: Carlos Henrique Reimer
Date:
Subject: Re: Low values for cached size
Next
From: Devrim GÜNDÜZ
Date:
Subject: Re: Can't find SRPMs for PG 8.1.18 on RHEL4