pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Building a list of fields ?
2+ messages / 2 participants
[nested] [flat]

* Building a list of fields ?
@ 2005-01-19 17:38  David.Jacques@CCRS.NRCan.gc.ca
  0 siblings, 1 reply; 2+ messages in thread

From: David.Jacques@CCRS.NRCan.gc.ca @ 2005-01-19 17:38 UTC (permalink / raw)
  To: pgsql-admin

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 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.





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Building a list of fields ?
@ 2005-01-19 18:20  Michael Fuhr <mike@fuhr.org>
  parent: David.Jacques@CCRS.NRCan.gc.ca
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Fuhr @ 2005-01-19 18:20 UTC (permalink / raw)
  To: David.Jacques@CCRS.NRCan.gc.ca; +Cc: pgsql-admin

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/



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-01-19 18:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-19 17:38 Building a list of fields ? David.Jacques@CCRS.NRCan.gc.ca
2005-01-19 18:20 ` Michael Fuhr <mike@fuhr.org>

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