[Zope-DB] Floating point problem with Oracle
Coi Giovanni
coi.giovanni@prometeo.it
Tue, 29 Oct 2002 15:01:50 +0100
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.
running this code:
-------------------------------------------------
import DCOracle2
print DCOracle2.version
db = DCOracle2.connect('lr28/startr3k@artu')
c = db.cursor()
c.execute( 'select PRIZE as v1, PRIZE * 100 as v2 from MOV')
ris=c.fetchall()
print ris
print ris[0][0], type( ris[0][0])
print ris[0][1], type( ris[1][0])
print (ris[0][0]) * 100
print c.description[0][1]
print c.description[0][2]
-------------------------------------------------
the results are:
1.2 -- DCOracle2 1.95 (dco2: 1.120 -DORACLE8i -DUSEOBJECT -Dlinux -
D_REENTRANT )
[[1000.0, 100065.0], [1000.0, 100023.0], [1000.0, 100023.0], [1000.0, 100023.0]]
1000.0 <type 'float'>
100065.0 <type 'float'>
100000.0
NUMBER
22
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
_________________________________________________________
Prometeo srl - The Software Experience
Coi Giovanni
Voice : +39 (041)5701366 Via Giudecca 15
Fax : +39 (041)5701005 30035 MIRANO (VE) - ITALY
e-mail: coi@prometeo.it http://www.prometeo.it