Re: stored procedure: RETURNS record

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Rob Marjot <rob(at)marjot-multisoft(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: stored procedure: RETURNS record
Date: 2009-09-26 00:27:59
Message-ID: b42b73150909251727i3d9ed6b2j562133fe5bab1a0d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 25, 2009 at 2:40 PM, Rob Marjot <rob(at)marjot-multisoft(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2009-09-26 00:42:21 Re: Can't find SRPMs for PG 8.1.18 on RHEL4
Previous Message Carlos Henrique Reimer 2009-09-25 23:47:49 Re: Low values for cached size