Re: [SQL] Getting datatype before SELECT - Mailing list pgsql-sql

From darcy@druid.net (D'Arcy J.M. Cain)
Subject Re: [SQL] Getting datatype before SELECT
Date
Msg-id m0zOujg-00006FC@druid.net
Whole thread Raw
In response to Re: [SQL] Getting datatype before SELECT  (Glenn Sullivan <glenn.sullivan@nmr.varian.com>)
List 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@{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.

pgsql-sql by date:

Previous
From: Glenn Sullivan
Date:
Subject: Re: [SQL] Getting datatype before SELECT
Next
From: phansen
Date:
Subject: grouping a ordered list