[ZWeb] Zope.org feedback: DCOracle2 bug: real numbers

Stepan Skrob (via www.zope.org) stepan@firma.seznam.cz
Wed, 22 May 2002 10:21:03 -0400


hello,

i found problem with DCOracle2 when retrieving real numbers
from database and NLS_LANG is set to Czech. try this:

#within oracle run:
create table aaa (id number(1) primary key, a number(6,3), b number(6,3));
insert into aaa values (1, 1.34, 3.2);
insert into aaa values (2, 0.333, 234.2);
insert into aaa values (3, 0.1, 123.8);
insert into aaa values (4, 1, 2.001);
insert into aaa values (5, 0.23, 10.8);
commit;


#necessary oracle environment is set as follows:
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/product/8.1.6


#good execution (NLS_LANG not set):
bitch:~# unset NLS_LANG   
bitch:~# python2.1
Python 2.1.2 (#1, Jan 30 2002, 15:20:58) 
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import DCOracle2
>>> db=DCOracle2.connect("firm/firmy@d4v817.kancelar.seznam.cz")
>>> cur=db.cursor()
>>> cur.execute("select * from aaa")
1
>>> bb=cur.fetchall()
>>> cur.close()
>>> print bb
[[1, 1.3400000000000001, 3.2000000000000002], [2, 0.33300000000000002, 234.19999999999999], [3, 0.10000000000000001, 123.8], [4, 1.0, 2.0009999999999999], [5, 0.23000000000000001, 10.800000000000001]]
>>>

#broken execution (NLS_LANG set):
bitch:~# export NLS_LANG="czech_czechoslovakia.EE8ISO8859P2"
bitch:~# python2.1
Python 2.1.2 (#1, Jan 30 2002, 15:20:58) 
[GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import DCOracle2
>>> db=DCOracle2.connect("firm/firmy@d4v817.kancelar.seznam.cz")
>>> cur=db.cursor()
>>> cur.execute("select * from aaa")
1
>>> bb=cur.fetchall()
>>> cur.close()
>>> print bb
[[1, 1.0, 3.0], [2, 9.8541102177194901e-270, 234.0], [3, 9.8541102177194901e-270, 123.0], [4, 1.0, 2.0], [5, 9.8541102177194901e-270, 10.0]]
>>>

----
this is probably because czech NLS settings
causes decimal point to be a comma (,) instead
of dot (.) usual in u.s.
setting NLS_NUMERIC_CHARACTERS=".," probably
corrected the problem, but i did not tested
it for large numbers.

----
thank you
stepan


----------------------------------------------------------
This email was generated from the Zope.org feedback form
It was invoked from a link on http://www.zope.org/Members/matt/dco2