Extracting fieldnames from a TABLE

From: Erik Wasser <erik(dot)wasser(at)iquer(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Extracting fieldnames from a TABLE
Date: 2004-09-01 15:14:49
Message-ID: 200409011714.49671.erik.wasser@iquer.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi community,

I would like to retrieve all the fieldnames of a given table. In the
perl module Tie::DBI[1] i found the following fragment:

$dbh->prepare("LISTFIELDS $table");

in the case the DB supports this (Tie::DBI thinks so for Pg) or the
alternative is:

$dbh->prepare("SELECT * FROM $table WHERE 0=1");

The first one doesn't work in my PostgreSQL 7.4.3:

% LISTFIELDS foobar;
ERROR: syntax error at or near "LISTFIELDS" at character 1
%

and the seconds one looks ugly. Is there a solution for the problem?

Greetings

[1]http://search.cpan.org/~lds/Tie-DBI-0.93/lib/Tie/DBI.pm

--
So long... Fuzz

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Robert Strötgen 2004-09-01 15:17:09 Re: German "umlaut insensitive" query
Previous Message Michael Kleiser 2004-09-01 14:36:11 Re: German "umlaut insensitive" query