From: Michael Fuhr <mike@fuhr.org>
To: David.Jacques@CCRS.NRCan.gc.ca
Cc: pgsql-admin@postgresql.org
Subject: Re: Building a list of fields ?
Date: Wed, 19 Jan 2005 11:20:01 -0700
Message-ID: <20050119182001.GA95507@winnie.fuhr.org> (raw)
In-Reply-To: <B7F9814D6850C949947CF8DEA13477810207AB89@s5-ccr-r2.ccrs.nrcan.gc.ca>
References: <B7F9814D6850C949947CF8DEA13477810207AB89@s5-ccr-r2.ccrs.nrcan.gc.ca>
On Wed, Jan 19, 2005 at 12:38:11PM -0500, David.Jacques@CCRS.NRCan.gc.ca wrote:
> I'm trying to make a generic function InsertValues().
>
> In order to do this (cleanly) I need to construct a field list from
> the table name passed in as an argument. However I see no libpq function
> to return the field names of a table. Does such a thing exist ?
I don't see a function that specifically returns a table's structure,
but you can use the functions listed under "Retrieving Query Result
Information" to inspect the results of a query against that table.
> I thought I was on to something by using the pg_attribute system table,
> but there is no field to relate a column to its table.
Yes there is -- attrelid is the table's OID. You can join attrelid
with pg_class.oid.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mike@fuhr.org, David.Jacques@CCRS.NRCan.gc.ca
Subject: Re: Building a list of fields ?
In-Reply-To: <20050119182001.GA95507@winnie.fuhr.org>
References: <B7F9814D6850C949947CF8DEA13477810207AB89@s5-ccr-r2.ccrs.nrcan.gc.ca> <20050119182001.GA95507@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox