Create a view with variable amount of columns depending on the rows of a table

From: Stefan Gündhör <stefan(at)guendhoer(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Create a view with variable amount of columns depending on the rows of a table
Date: 2011-03-14 19:22:21
Message-ID: AANLkTi=2EddLbjLEq_e6__a9i4NraxyVjMsuhuWHd8hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

If I have following tables for example:

# Main Table:

id(id/pk) | geometry
---------------------------
1 | ...

# Additional Attribute Table:

name(id/pk) | value
---------------------------
date_added | 20.12.1988
name | Vienna

# m:n table:

mainTableID | attrTableID
-----------------------------------
1 | date_added
1 | name

And i would like to automatically generate a View like
the following:

id(id/pk) | geometry | date_added | name
-----------------------------------------------------------
1 | ... | 20.12.1988 | Vienna

This example is a simplified (and not really functional) version of what I
would like to do -
but it should make clear what I have in view: Dynamically generating a
View's columns depending on the rows of a table.

Does anybody know, if this is possible?

Thank you for your replies in advance,
best regards,
Stefan Gündhör

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2011-03-14 19:33:22 Re: Move From Oracle DB to PostgreSQL DB
Previous Message Michael Nolan 2011-03-14 18:56:17 Re: DBMS upgrade and backups