Received: from druid.net (root@druid.net [198.96.119.226]) by hub.org (8.9.1/8.9.1) with SMTP id RAA14929 for ; Tue, 10 Nov 1998 17:28:10 -0500 (EST) (envelope-from darcy@druid.net) Received: from localhost (1961 bytes) by druid.net via sendmail with P:stdio/R:inet_hosts/T:smtp (sender: ) (ident using unix) id for ; Tue, 10 Nov 1998 17:27:42 -0500 (EST) (Smail-3.2.0.102 1998-Aug-2 #4 built 1998-Nov-4) Message-Id: From: darcy@druid.net (D'Arcy J.M. Cain) Subject: Re: [INTERFACES] Determine data type of columns To: bryan@arcamax.com (Bryan White) Date: Tue, 10 Nov 1998 17:27:41 -0500 (EST) Cc: pgsql-interfaces@postgreSQL.org In-Reply-To: <012001be0cf0$131ffb60$a3f0f6ce@bryan.arcamax.com> from "Bryan White" at Nov 10, 1998 04:21:26 PM X-Mailer: ELM [version 2.5 PL0b1] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Thus spake Bryan White > This brings me to my question. The PQftype function returns an OID but I > don't see any documentation on how to interpret it. Are the values constant > for the built in types (specifically int4, text, and date)? > Do I have to execute another query to determine the actual type? > Is there a way to encode the values in an insert/update statement such that > they will be quietly converted to the proper type on the backend? Look at how I do it in PyGreSQL. The code is available at http://www.druid.net/pygresql/ First, I run this Python script to get the proper OIDs. #! /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, This gets me my #defines. My assumption is that if it isn't one of those then I just treat it as text. I include this in my C source with a comment about how naughty I am. Then I use these values in the functions that have to do the conversions. -- D'Arcy J.M. Cain | 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.