Received: from u1.abs.net (root@u1.abs.net [207.114.0.131]) by hub.org (8.8.8/8.8.8) with ESMTP id RAA09549 for ; Tue, 29 Sep 1998 17:49:35 -0400 (EDT) (envelope-from daveh@insightdist.com) Received: from insightdist.com (nobody@localhost) by u1.abs.net (8.9.0/8.9.0) with UUCP id RAA02726 for pgsql-sql@hub.org; Tue, 29 Sep 1998 17:32:08 -0400 (EDT) X-Authentication-Warning: u1.abs.net: nobody set sender to insightdist.com!daveh using -f Received: from ceodev by insightdist.com (AIX 3.2/UCB 5.64/4.03) id AA34461; Tue, 29 Sep 1998 17:24:38 -0400 Received: from daveh by ceodev (AIX 4.1/UCB 5.64/4.03) id AA29498; Tue, 29 Sep 1998 17:24:37 -0400 Message-Id: <361150FF.8FA8CB1F@insightdist.com> Date: Tue, 29 Sep 1998 17:28:31 -0400 From: David Hartwig Organization: Insight Distribution Systems X-Mailer: Mozilla 4.05 [en] (Win95; I) Mime-Version: 1.0 To: Glenn Sullivan Cc: pgsql-sql@hub.org Subject: Re: [SQL] Getting datatype before SELECT References: <199809230300.XAA12144@hub.org> <3611135E.491D2598@nmr.varian.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Glenn Sullivan wrote: > In my C code which communicates with the Postgres database, > I have the need to determine the datatype of a column, before > I have done a SELECT command. I have the name of the column, > but I cannot seem to figure out how to get the datatype information > until after I have done a SELECT. Then I can call PQfnumber() and > PQftype() to get the type. Does anyone know how to do this? -- will give you the attribute name SELECT pg_type.typname FROM pg_class, pg_type, pg_attribute WHERE pg_class.relname = 'your_table' AND pg_attribute.attname = 'your_attribute' AND pg_class.oid = pg_attribute.attrelid AND pg_attribute.atttypid = pg_type.oid;