[egenix-users] way to prevent floats from truncating to ints?

M.-A. Lemburg mal at egenix.com
Wed Apr 9 23:52:15 CEST 2008


On 2008-04-09 22:26, Nathan Gossett wrote:
> I'm using mxODBC to work with an Oracle 9 database, and when I try to 
> fetch FLOAT data, they are being returned as ints.  Basically, I'm 
> having the same issue as problem two in this posting:
> 
> http://www.egenix.com/mailman-archives/egenix-users/2003-June/113452.html
> 
> Setting the "leave scale 0 floats untouched" option is not really a 
> solution, because then all of the NUMBER(10,0) data is returned as 
> floats (which causes problems since they are supposed to be integers). I 
> realize that mxODBC is acting exactly as documented, but I need floats 
> to be returned as floating point numbers, while integers are returned as 
> integers.  Is there some way around this?

What you are seeing is caused by a bug in the Oracle ODBC driver
you are using: it returns a scale 0 value for regular floating
values instead of the true value. As a result the mxODBC Zope DA
then assumes that the scale of the float value is indeed 0 and
thus an integer and truncates the values depending on the setting
of the connection option.

There are ways to work around this problem by fetching all numbers
as floats and then applying the conversion from floats to integers
where necessary "by hand", but this is not ideal.

Please first try with the latest Oracle ODBC driver from the
Oracle Full Client (not the Oracle Instance Client), apply
all available patches and let us know whether the problem still
persists with that driver version.

If that doesn't help either, we'll have to add a work-around to the
underlying mxODBC Python interface and include that in the next version
of the mxODBC Zope DA.

Thanks,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 09 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the egenix-users mailing list