[Zope-DB] Floating point problem with Oracle
Matthew T. Kromer
matt@zope.com
Tue, 29 Oct 2002 10:28:31 -0500
Coi Giovanni wrote:
>Hi,
>
>we have a table (MOV) in Oracle with a filed like
>
>PRIZE NUMBER(13,3) with NULL
>
>values in this field are 1000.23, 1000.65, ecc.
>
>
[...]
>
>someone can tell us why the floating point v1 have no decimal values?
>The type is correct (float), the values into the table also (as you can see
>form v2 = v1 * 100).
>Where are my decimals?
>
>(You can see the same problem from Zope using ZSQLMethod)
>
>Platform:
>SuSE Linux 2.4.10
>Python 2.1.3
>DCOracle 2.1.2 (but the same with DCOracle 2.1.1)
>
>env variable about oracle or localization:
>ORACLE_SID=orcl
>ORACLE_BASE=/opt/oracle
>ORACLE_HOME=/opt/oracle/product/8.1.7
>ORA_NLS33=/opt/oracle/product/8.1.7/ocommon/nls/admin/data
>
>RC_LANG=it_IT
>NLS_LANG=ITALIAN_ITALY.WE8ISO8859P15
>
>
To handle LONG numbers, DCOracle2 fetches all numbers from Oracle as
strings, and then runs the C utility function sscanf() on them to
convert to a float when it needs to. Oracle is almost for sure
returning your values as 1000,23 1000,65 not 1000.23, 1000.65, right?
The indication is of a mismatch between the C locale and the Oracle locale.
Unfortunately, I tried to set my Oracle language like yours, and my
LC_ALL to it_IT, and sscanf() still mis-parsed my results. The best
information I have available to me is that it should do so.
--
Matt Kromer
Zope Corporation http://www.zope.com/