building a row with a plpgsql function

Поиск
Список
Период
Сортировка
От Raphael Bauduin
Тема building a row with a plpgsql function
Дата
Msg-id 4188DA87.1050307@be.easynet.net
обсуждение исходный текст
Ответы Re: building a row with a plpgsql function  (Michael Kleiser <mkl@webde-ag.de>)
Список pgsql-novice
Hi,

We have a table collectiong all details of an item:
Here is a simplified representation of the tables
Tables:

items
------
item_id


item_details
------------
item_detail_id
item_id
item_detail_name
item_detail_value


That way, we can easily have a variable number of detail for the items (some can have 10 details, some only one).
I wondered if it was possible to build a row with all details of an item. It would then be possible to do

select * from details(5);
which would return all details of item with item_id 5:

serial | customer | type
0012   | Mr Doe   | standard


because we have this :

select item_id, item_detail_name, item_detail_value from item_details where item_id=5;

item_id | item_detail_name | item_detail_value
-----------------------------------------------
      5 |           serial |              0012
      5 |         customer |            Mr Doe
      5 |             type |          standard



Thanks for your feedback.

Raph











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

Предыдущее
От: Kjetil Haaland
Дата:
Сообщение: c extension
Следующее
От: Michael Kleiser
Дата:
Сообщение: Re: building a row with a plpgsql function