_______________________________________________
Informix-list mailing list
Inform...@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
Art,
Based off you feedback I have tried a few things to try and get this to work with no success. I have tried making the parameter object have a type of String with a size of 1. This cause the ODBC driver to raise a Truncation exception (I knew I was truncating, but did not know it would be an exception). Next I tried removing the size limit on the parameter and did a substr of the first character in the update SQL. In ODBC this work, so I then switched to DRDA (DB2) and got same error message. Next I tried changing the SQL to use a DECODE with 1 going to‘t’ everything else to ‘f’ keeping the DBType as Boolean. DRDA still gave the same exception. I then changed the DBType to Int16, still same error.
I am baffled by how to handle this. I use far too many Booleans as part of datasets to be able to convert them all to retrieve a string and then convert it to a Boolean, and the use of Data Adapters would have to be stripped out for Data Reader / writers. I have several hundred tables that would be impacted by this change and the performance of the data reads and writes would suffer as a result.
It looks like I will have to stick with ODBC and the Informix driver. L
Thanks,
Ben Waters
Phone: 480-312-3101
Cell: 602-618-6471
Art,
I think you may be missing my problem. My issue is not in selecting the Boolean. In ODBC and DRDA they are selecting fine, it is doing the Insert / Updates.
I think the issue is at the driver level. When I created a function called StringToBoolean that takes in a Char(5) and returns a Boolean I cannot get the DRDA to return me anything but the same exception I have been seeing. No matter how I identify the parameter. When I run an update in Server Studio with ‘t’, ‘true’, 1, ETC it updates without issue.
I tried creating the implicit cast based on your suggestion (modified to handle the insert/update scenario), but that made all my tables with a char(5) value try to convert to a Boolean (in .Net and Server Studio). I then changed (dropped and recreated) the cast to an explicit cast (based on the SQL Reference document) and the issue of not accessing the data was still present.
I am using VB.Net 4.0 and ADO.Net on the client side, in case that makes a difference.
Thanks,
Ben Waters
From: Art Kagel
[mailto:art....@gmail.com]
Sent: Wednesday, January 25, 2012 12:12 PM
To: Waters, Benjamin
Cc: inform...@iiug.org
Subject: Re: Exception using IBM.Data.DB2 and DBType.Boolean
OK, I was mistaken, there is no implicit cast from boolean to char(1), but it is simple to create one. In your database do:
From: Art Kagel [mailto:art....@gmail.com]
Art,
The error with the cast was occurring on SELECT from a table that has a CHAR(5) or a VARCHAR or LVARCHAR with a length of 5 characters. I agree, very odd.
Thanks,
Ben Waters
Systems Integrator
Scottsdale City Court