X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1DEEF3A4476 for ; Wed, 19 Jan 2005 18:21:22 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30072-05 for ; Wed, 19 Jan 2005 18:21:15 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0C7BA3A4523 for ; Wed, 19 Jan 2005 18:20:20 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j0JIK17j005469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jan 2005 11:20:04 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j0JIK1ot095561; Wed, 19 Jan 2005 11:20:01 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j0JIK1UD095560; Wed, 19 Jan 2005 11:20:01 -0700 (MST) (envelope-from mfuhr) Date: Wed, 19 Jan 2005 11:20:01 -0700 From: Michael Fuhr To: David.Jacques@CCRS.NRCan.gc.ca Cc: pgsql-admin@postgresql.org Subject: Re: Building a list of fields ? Message-ID: <20050119182001.GA95507@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/200 X-Sequence-Number: 16059 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/