find column names from query

Поиск
Список
Период
Сортировка
От Afton & Ray Still
Тема find column names from query
Дата
Msg-id 008201c501e0$66f1c570$7c884146@rayshome
обсуждение исходный текст
Ответ на Upgrade from v8rc5 to 8.0.0 fails  ("Keith Worthington" <keithw@narrowpathinc.com>)
Ответы Re: find column names from query  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-novice
Hello,
I'm trying to find a way to get the column names of a table, knowing only the table name. (I'm trying to display the contents of various hidden support tables to the DB administrator) 
 
here's what's happening:
user picks a table name from a select list (HTML),
a SELECT * FROM selected_table ... query is sent (PHP)
nested for loops print out the table data (PHP and HTML)
works great to here, although I realize I'm cheating a little.
problem is the data has no column labels.
 
going through the documentation I found the following:
 
SELECT attname::regclass FROM pg_attribute WHERE attrelid = travel::regclass 
 
I'm trying to get the attname, which should be the column name, from the pg_attribute "table"(or catalog?) when attrelid, which should be the table name, which I have.
 
trying this query in PgadminIII I get:
ERROR:  cannot cast type name to regclass 
 
I could go through and hardcode the table data into the application, but I'd prefer not to.
 
Any suggestions to make this work, or for better methods appreciated.
Ray

В списке pgsql-novice по дате отправления:

Предыдущее
От: Keith Worthington
Дата:
Сообщение: Re: Upgrade from v8rc5 to 8.0.0 fails
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: find column names from query