Re: function SETOF return type with variable columns?

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "James Neff" <james(dot)neff(at)tethyshealth(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function SETOF return type with variable columns?
Date: 2008-08-20 19:43:29
Message-ID: 162867790808201243x3a537a9dt8894cb8496193114@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2008/8/20 James Neff <james(dot)neff(at)tethyshealth(dot)com>:
> Greetings,
>
> Is it possible to have a function with a return type of SETOF that has
> variable number of return columns?
>

No. Number and result types have to be known in parse time. Use array
without it.

> The input parameter for this function will be a String containing a number
> of codes separated by a tilde character. I would like to have 1 output
> column for each of these codes, but the number of input codes may change for
> each time the function is called.
>
> For example:
>
> Input: ABC1~XYZ2~MNO3
>

simply string_to_array('ABC1~XYZ2~MNO3', '~');

>
> Output result set will then look like this where name, ABC1, XYZ2, and MNO3
> are column headers and not a data row:
>
> name | ABC1 | XYZ2 | MNO3
> bob | 9 | 3 | 1
> john | 5 | 2 | 1
> ...
>
>
> Every row in the output set will contain a name and then a count of the
> number of codes matched for that name. But the codes queried for would
> change with each call of the function.
> Does it make sense what I am asking for?

it has sense, but postgresql doesn't support this feature
Regards
Pavel Stehule

>
> Thanks in advance,
> James
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Pettis 2008-08-20 19:47:44 Re: How do I determine my data dir for a created database for pg_ctl?
Previous Message Barbara Figueirido 2008-08-20 19:38:41 Re: How do I determine my data dir for a created database for pg_ctl?