building a row with a plpgsql function

From: Raphael Bauduin <raphael(dot)bauduin(at)be(dot)easynet(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: building a row with a plpgsql function
Date: 2004-11-03 13:17:59
Message-ID: 4188DA87.1050307@be.easynet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Kleiser 2004-11-03 13:42:57 Re: building a row with a plpgsql function
Previous Message Lars Eckberg 2004-11-03 11:42:32 function to update different tables