pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Hartwig <daveh@insightdist.com>
To: Glenn Sullivan <glenn.sullivan@nmr.varian.com>
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] Getting datatype before SELECT
Date: Tue, 29 Sep 1998 17:28:31 -0400
Message-ID: <361150FF.8FA8CB1F@insightdist.com> (raw)
References: <199809230300.XAA12144@hub.org>
	<3611135E.491D2598@nmr.varian.com>



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;








view thread (11+ messages)  latest in thread

Message-ID: <361150FF.8FA8CB1F@insightdist.com>
Permalink:  ../361150FF.8FA8CB1F@insightdist.com/
Also on:    postgresql.org/message-id/361150FF.8FA8CB1F@insightdist.com

 · 

reply

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-sql@postgresql.org
  Cc: daveh@insightdist.com, glenn.sullivan@nmr.varian.com, pgsql-sql@hub.org
  Subject: Re: [SQL] Getting datatype before SELECT
  In-Reply-To: <361150FF.8FA8CB1F@insightdist.com>
  References: <199809230300.XAA12144@hub.org> <3611135E.491D2598@nmr.varian.com> <361150FF.8FA8CB1F@insightdist.com>

* 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