Re: Return unknown resultset from a function

From: David Johnston <polobo(at)yahoo(dot)com>
To: Jan Meyland Andersen <jma(at)agile(dot)dk>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Return unknown resultset from a function
Date: 2012-03-04 20:00:24
Message-ID: 7445EC21-741B-42C0-BA04-79FFE34A573C@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mar 4, 2012, at 14:52, Jan Meyland Andersen <jma(at)agile(dot)dk> wrote:

> How do I return an unknown resultset from a function
>
> My main problem is that I do not know how many columns or the data type of the columns before runtime.
> It this possible at all?
>
> I also tried to return the data as a text array but I also have trouble with that.
>
> Regards
>
> Jan
>

Try HSTORE.

You can return RECORD from the function but the SQL user still has to define the names/types at design time.

Text array should work but you lose column names which HSTORE maintains.

You could also return a delimited string and then split it in the calling routine.

David J

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-03-04 20:11:45 Re: || versus concat( ), diff behavior
Previous Message Pavel Stehule 2012-03-04 19:57:13 Re: Return unknown resultset from a function