Booleans in DBD-Informix-0.59
Posted in 1998
Topics: Connectivity: ODBC / JDBC / .NET, Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
I ran across a small problem in trying to fetch a boolean type from our Informix database. The exact error message one gets is: DBD::Informix::dbd_ix_st_fetch - Unknown type code: 45 (no IUS support) (where 45 is defined in $INFORMIXDIR/incl/esql/sqltypes.h as SQLBOOL) It may be a small omission. It was surprisingly easy to add in this type: basically I defined boolean as a small int. Attached please find the small diff files to odbctype.c and dbdimp.ec. I should mention that I haven't tested things extensively. The Informix document that might describe definitively how booleans behave might be the Informix ESQL/C Programmers manual which I don't have. But looking at $INFORMIXDIR/incl/esql/value.h, there is some justification for booleans as small ints. Also it seems that a "null" boolean value is handled as a negative number. I'm not sure I got this right either. Overall though, there is much good work on DBD and DBI which I have been greatly enjoying. These have been a invaluable. --wYpqmPjGuZ Content-Type: text/ascii Content-Description: diff -c of odbctype.c.ORIG odbctype.c Content-Disposition: inline; filename="odbctype.c.diff" Content-Transfer-Encoding: 7bit *** odbctype.c.ORIG Thu Jan 15 14:38:13 1998 --- odbctype.c Sat Jul 18 21:00:51 1998 *************** *** 36,41 **** --- 36,42 ---- ix_VARCHAR = SQLVCHAR, ix_NVARCHAR = SQLNVCHAR, ix_INTEGER = SQLINT, + ix_BOOL = SQLBOOL, ix_SMALLINT = SQLSMINT, ix_SERIAL = SQLSERIAL, ix_TEXT = SQLTEXT, *************** *** 142,147 **** --- 143,149 ---- case ix_INTEGER: odbctype = SQL_INTEGER; break; + case ix_BOOL: case ix_SMALLINT: odbctype = SQL_SMALLINT; break; *************** *** 203,208 **** --- 205,211 ---- odbcprec = 10; break; case ix_SMALLINT: + case ix_BOOL: odbcprec = 5; break; case ix_FLOAT: *************** *** 254,259 **** --- 257,263 ---- break; case ix_INTEGER: case ix_SMALLINT: + case ix_BOOL: case ix_SERIAL: odbcscale = 0; break; --wYpqmPjGuZ Content-Type: text/ascii Content-Description: diff -c of dbdimp.ec.ORIG dbdimp.ec Content-Disposition: inline; filename="dbdimp.ec.diff" Content-Transfer-Encoding: 7bit *** dbdimp.ec.ORIG Thu Jan 15 13:46:25 1998 --- dbdimp.ec Sun Jul 19 00:07:06 1998 *************** *** 1407,1412 **** --- 1407,1413 ---- case SQLINT: case SQLSERIAL: case SQLSMINT: + case SQLBOOL: case SQLDATE: case SQLDTIME: case SQLINTERVAL: --wYpqmPjGuZ--