Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 3C6939FA2BB for ; Tue, 24 Jul 2007 11:23:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 94405-03-7 for ; Tue, 24 Jul 2007 11:23:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sargon.lncsa.com (sargon.lncsa.com [212.99.8.251]) by postgresql.org (Postfix) with ESMTP id EE5E59FA1AB for ; Tue, 24 Jul 2007 11:23:29 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 443103040607 for ; Tue, 24 Jul 2007 16:23:28 +0200 (CEST) Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zvO8Rdz7E6NN for ; Tue, 24 Jul 2007 16:23:28 +0200 (CEST) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id 1E2EA3040104 for ; Tue, 24 Jul 2007 16:23:28 +0200 (CEST) Received: from trajan.apartia.fr (trajan.apartia.fr [10.0.3.121]) by zenon.apartia.fr (Postfix) with ESMTP id E20B9F0A253BF for ; Tue, 24 Jul 2007 16:23:26 +0200 (CEST) Received: by trajan.apartia.fr (Postfix, from userid 1000) id 17E952524368; Tue, 24 Jul 2007 16:23:29 +0200 (CEST) Date: Tue, 24 Jul 2007 16:23:29 +0200 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: is there a 'table' data type in pg? Message-ID: <20070724142328.GA25489@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20070724124246.GA22602@apartia.fr> <87sl7d28pn.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sl7d28pn.fsf@oxford.xeocode.com> User-Agent: Mutt/1.5.16 (2007-06-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/140 X-Sequence-Number: 28875 On Tue, Jul 24, 2007 at 03:10:44PM +0100, Gregory Stark wrote: > "Louis-David Mitterrand" 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. Bummer, I suspected as much. > 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. Good fallback solution. > 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. Will look at that one, always willing to dig deeper into pg's more complex ways :) Thanks for your help,