pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gregory Stark <stark@enterprisedb.com>
To: pgsql-sql@postgresql.org
Subject: Re: is there a 'table' data type in pg?
Date: Tue, 24 Jul 2007 15:10:44 +0100
Message-ID: <87sl7d28pn.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <20070724124246.GA22602@apartia.fr>
References: <20070724124246.GA22602@apartia.fr>

"Louis-David Mitterrand" <vindex+lists-pgsql-sql@apartia.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




view thread (4+ messages)  latest in thread

Message-ID: <87sl7d28pn.fsf@oxford.xeocode.com>
Permalink:  ../87sl7d28pn.fsf@oxford.xeocode.com/
Also on:    postgresql.org/message-id/87sl7d28pn.fsf@oxford.xeocode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: stark@enterprisedb.com
  Subject: Re: is there a 'table' data type in pg?
  In-Reply-To: <87sl7d28pn.fsf@oxford.xeocode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox