Re: [SQL] Getting datatype before SELECT

From: darcy(at)druid(dot)net (D'Arcy J(dot)M(dot) Cain)
To: glenn(dot)sullivan(at)nmr(dot)varian(dot)com (Glenn Sullivan)
Cc: herouth(at)oumail(dot)openu(dot)ac(dot)il (herouth maoz), pgsql-sql(at)hub(dot)org
Subject: Re: [SQL] Getting datatype before SELECT
Date: 1998-10-02 02:14:24
Message-ID: m0zOujg-00006FC@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thus spake Glenn Sullivan
> The value I get returned from PQftype() for a varchar is 1043
> and for an int is 23.
> I am uncomfortable just testing for these values. I could
> not find in the documentation, what the return values of
> PQftype() are. Can anyone point me to that information?

Here's a Python script to generate #defines for a C header. I'm sure
you can figure out how to convert it for your needs.

#! /usr/local/bin/python
import string

# change this if you have it somewhere else
for l in open("/usr/local/pgsql/src/include/catalog/pg_type.h").readlines():
tokens = string.split(l)
if len(tokens) == 0 or tokens[0] != "#define": continue
if tokens[1] in ('CASHOID', 'INT2OID', 'INT4OID', 'OIDOID', 'FLOAT4OID', 'FLOAT8OID'):
print l,

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message phansen 1998-10-03 06:50:57 grouping a ordered list
Previous Message Glenn Sullivan 1998-10-01 17:39:57 Re: [SQL] Getting datatype before SELECT