building a row with a plpgsql function - Mailing list pgsql-novice

From Raphael Bauduin
Subject building a row with a plpgsql function
Date
Msg-id 4188DA87.1050307@be.easynet.net
Whole thread Raw
Responses Re: building a row with a plpgsql function
List 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 by date:

Previous
From: Kjetil Haaland
Date:
Subject: c extension
Next
From: Michael Kleiser
Date:
Subject: Re: building a row with a plpgsql function