Re: How access table by tableoid

From: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
To: Felix Kater <fkater(at)googlemail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How access table by tableoid
Date: 2007-05-13 22:54:43
Message-ID: 20070513225443.GE69517@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, May 13, 2007 at 09:25:37PM +0200, Felix Kater wrote:
> can I use a given tableoid (instead of the tablename) to select
> columns from that table somehow?
>
> SELECT * FROM ??tableoid??
<snip>
> So, I worked around that by peforming two queries: The first to retrieve
> the table's name from pg_class via its OID, the second to select the
> wanted columns from that table using the table's name as usual.
>
> Can I do it in one go using the table??s OID?

You could possibly do this with a SRF; you'd have to grab the name of
the table and then build a dynamic query off of that. If you cast the
oid to regclass you'll get the name of the table, though you should
probably query pg_class and pg_namespace to build a fully-qualified
table name (schemaname.tablename).
--
Jim Nasby decibel(at)decibel(dot)org
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2007-05-14 01:04:53 Re: [GENERAL] PITR and tar
Previous Message Jim C. Nasby 2007-05-13 22:50:17 Re: Internals of PostgreSQL - Documentation or presentations