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