i'm having issues with reading floats from oracle. i have the following snippet:
sqlstr='select prio from tabletest'
statement = None
if connection is not None:
try:
statement = connection.prepareStatement(sqlstr)
if connection is not None:
rs = statement.executeQuery()
if rs is not None:
#statement.closeOnComplete()
while (rs.next()):
NWW = rs.getFloat(1)
print (NWW)
rs.close()
else:
statement.close()
except:
pass
finally:
connection.close()
this gets me this:
0.5
0.5
0.5
0.20000000298
0.5
0.990000009537
0.5
0.5
0.699999988079
but my actual data in the db looks like this:
0,5
0,5
0,5
0,2
0,5
0,99
0,5
0,5
0,7
the db is defined as:
CREATE TABLE "SYSTEM"."tabletest"
( "NWW" NUMBER(12,8)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM" ;
as you can see, the float are only precise having prio=0.5 ... is there any option I can set that the floats are precise?
thanks, E.
... a bit embarassing, but rs.getDouble(1) solved my issue. :)