Re: is there a 'table' data type in pg?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: is there a 'table' data type in pg?
Date: 2007-07-24 14:10:44
Message-ID: 87sl7d28pn.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Louis-David Mitterrand" <vindex+lists-pgsql-sql(at)apartia(dot)org> writes:

> Can I use a another column to store the type of the id_subject (ie: the
> tabled it belongs to) ? Then I would be able to query that table for
> additional info to print alongside the forum posts.

There are ways to identifier tables in Postgres but there's no way to run a
query against a table using them.

I would strongly recommend you define your own list of "object_types",
probably even have an object_type table with a primary key, a description
column, and a table_name column. Then you can in your application construct
the appropriate query depending on the object_type.

One alternative you could do is have a set-returning plpgsql function which
has a big if statement and performs the right kind of query. I think the
records would have to all be the same -- they can't be different kinds of
records depending on the type of object.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2007-07-24 14:23:29 Re: is there a 'table' data type in pg?
Previous Message Louis-David Mitterrand 2007-07-24 12:42:46 is there a 'table' data type in pg?