| From: | Felix Kater <fkater(at)googlemail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | How access table by tableoid |
| Date: | 2007-05-13 19:25:37 |
| Message-ID: | 20070513212537.83b36cde.fkater@googlemail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi,
can I use a given tableoid (instead of the tablename) to select
columns from that table somehow?
SELECT * FROM ??tableoid??
My first approach was to lauch a subquery of the information_schema
like this:
SELECT * FROM (SELECT relname FROM pg_class WHERE oid=999) AS
tablename
However, it turned out that the subquery returns the refered *column*
which is the 'relname' column but not the table's name. (With other
words: The final result is a single 'relname' column instead of all
columns from the tablename inside the relname column.) This is not was I
intended.
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?
Thank You
Felix
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrus | 2007-05-13 20:42:44 | How to implement GOMONTH function |
| Previous Message | Gerhard Wiesinger | 2007-05-13 18:44:48 | Internals of PostgreSQL - Documentation or presentations |