Need help with a function boolean --> text or array

Поиск
Список
Период
Сортировка
От Andreas
Тема Need help with a function boolean --> text or array
Дата
Msg-id 4796C06E.4010105@gmx.net
обсуждение исходный текст
Ответы Re: Need help with a function boolean --> text or array  ("Vyacheslav Kalinin" <vka@mgcp.com>)
Re: Need help with a function boolean --> text or array  ("Andrej Ricnik-Bay" <andrej.groups@gmail.com>)
Список pgsql-novice
Hi,

I've got a table with a couple of boolean columns which represent
attributes of entities.
Now I need to list those entities with the attributes cumulated into one
text-column.
How could I do this?

Silly example:
table: pizzas
id   integer,
name text,
has_olive   boolean,
has_cheese   boolean,
has_onion   boolean,
has_salami   boolean,
has_egg   boolean,
has_extra_hot_chilies boolean
....

My view should look like this:
id, name, addons
...
11, 'Salami',  'Cheese, Salami'
42, 'Fire',  'Cheese, Onion, Salami, Extra hot chilies'
...

Now I need a function that adds strings with commas in between (but not
at the front or end) acording to the boolean-columns into one
text-column that appears only in the view but isn't stored permanently.

The function has to work on the current record of the view but without
having to give it every single boolean as parameter.
Something like this would be nice:
SELECT id, name, fctAddons() FROM pizzas;

I'm not very hot in stored procedures, yet.
Could someone give me a clue how to get this done?


Regards
Andreas

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: domains, types, constraints
Следующее
От: "Vyacheslav Kalinin"
Дата:
Сообщение: Re: Need help with a function boolean --> text or array