Thread: [cx-oracle-users] How to read 16-digit numbers?
Brought to you by:
atuining
From: Guido v. R. <gu...@el...> - 2004-09-01 14:10:27
|
A certain table in our Oracle database contains 16-digit integers. These are a bit of a pain to get right at the best of times, but "set numformat 9999999999999999" makes it work in SQL*Plus. Now my colleague is complaining that when using cx_Oracle, the values come back with the lower digit(s?) truncated, as if they have somehow been converted to a floating point type and back that doesn't have enough bits. This seems strange to me, since an IEEE float *does* have enough bits for the values, and Python has no trouble with these at all. What are we missing? (A sample value is 1234567800000001.) --Guido van Rossum (home page: http://www.python.org/~guido) |
From: D.R. B. <da...@as...> - 2004-09-01 15:21:26
|
Hoi Guido, All I can say is that the following works fine for me % python Python 2.3.3 (#1, May 24 2004, 12:04:05) [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-24)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle as odbc >>> >>> print odbc.version 4.0.1 >>> >>> database =3D odbc.connect('ops$danny','ez','awtst.omegatest.nova.aw') >>> cursor =3D database.cursor() >>> cursor.execute('select 1234567800000001 from dual where 123456780000= 0001=3D:a',a=3D1234567800000001L) [<NumberVar object at 0xb72f01d0>] >>> print cursor.fetchall() [(1234567800000001L,)] >>> cursor.close() Both binding and fetching seems to be ok, so it looks like a more complex example is needed to expose your colleagues problem. Cheers, Danny Kapteyn Institute / OmegaCEN e-mail: da...@as... Postbus 800 tel.: +31 (0)50 3634056 9700 AV GRONINGEN fax.: +31 (0)50 3636100 THE NETHERLANDS http://www.astro-wise.org/ On Wed, Sep 01, 2004 at 07:10:22AM -0700, Guido van Rossum wrote: > A certain table in our Oracle database contains 16-digit integers. > These are a bit of a pain to get right at the best of times, but "set > numformat 9999999999999999" makes it work in SQL*Plus. Now my colleague > is complaining that when using cx_Oracle, the values come back with the > lower digit(s?) truncated, as if they have somehow been converted to a > floating point type and back that doesn't have enough bits. This seems > strange to me, since an IEEE float *does* have enough bits for the > values, and Python has no trouble with these at all. What are we > missing? (A sample value is 1234567800000001.) >=20 > --Guido van Rossum (home page: http://www.python.org/~guido) >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_idP47&alloc_id=10808&op?k > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |
From: Anthony T. <an...@co...> - 2004-09-01 16:35:41
|
Version 4.0 and up handle both binding and fetching of long integers properly, I believe -- there are test cases that ensure this fact. Could you tell us which version of cx_Oracle you are using? Thanks. D.R. Boxhoorn wrote: > Hoi Guido, > > All I can say is that the following works fine for me > > % python > Python 2.3.3 (#1, May 24 2004, 12:04:05) > [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-24)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import cx_Oracle as odbc > >>> > >>> print odbc.version > 4.0.1 > >>> > >>> database = odbc.connect('ops$danny','ez','awtst.omegatest.nova.aw') > >>> cursor = database.cursor() > >>> cursor.execute('select 1234567800000001 from dual where 1234567800000001=:a',a=1234567800000001L) > [<NumberVar object at 0xb72f01d0>] > >>> print cursor.fetchall() > [(1234567800000001L,)] > >>> cursor.close() > > Both binding and fetching seems to be ok, so it looks like a more complex > example is needed to expose your colleagues problem. > > Cheers, > > Danny > > Kapteyn Institute / OmegaCEN e-mail: da...@as... > Postbus 800 tel.: +31 (0)50 3634056 > 9700 AV GRONINGEN fax.: +31 (0)50 3636100 > THE NETHERLANDS http://www.astro-wise.org/ > > > On Wed, Sep 01, 2004 at 07:10:22AM -0700, Guido van Rossum wrote: > >>A certain table in our Oracle database contains 16-digit integers. >>These are a bit of a pain to get right at the best of times, but "set >>numformat 9999999999999999" makes it work in SQL*Plus. Now my colleague >>is complaining that when using cx_Oracle, the values come back with the >>lower digit(s?) truncated, as if they have somehow been converted to a >>floating point type and back that doesn't have enough bits. This seems >>strange to me, since an IEEE float *does* have enough bits for the >>values, and Python has no trouble with these at all. What are we >>missing? (A sample value is 1234567800000001.) >> >>--Guido van Rossum (home page: http://www.python.org/~guido) >> >> >>------------------------------------------------------- >>This SF.Net email is sponsored by BEA Weblogic Workshop >>FREE Java Enterprise J2EE developer tools! >>Get your free copy of BEA WebLogic Workshop 8.1 today. >>http://ads.osdn.com/?ad_idP47&alloc_id808&op?k >>_______________________________________________ >>cx-oracle-users mailing list >>cx-...@li... >>https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_idP47&alloc_id808&op=click > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users -- Anthony Tuininga an...@co... Computronix Distinctive Software. Real People. Suite 200, 10216 - 124 Street NW Edmonton, AB, Canada T5N 4A3 Phone: (780) 454-3700 Fax: (780) 454-3838 http://www.computronix.com |