function SETOF return type with variable columns?

Поиск
Список
Период
Сортировка
От James Neff
Тема function SETOF return type with variable columns?
Дата
Msg-id 48AC4D76.5090105@tethyshealth.com
обсуждение исходный текст
Ответы Re: function SETOF return type with variable columns?
Re: function SETOF return type with variable columns?
Список pgsql-general
Greetings,

Is it possible to have a function with a return type of  SETOF that has
variable number of return columns?

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


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?

Thanks in advance,
James



В списке pgsql-general по дате отправления:

Предыдущее
От: Mark Roberts
Дата:
Сообщение: Re: SELECT query experts, anyone?
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: Is the primary key constraint also an index?