integers are being inserted instead of floats using executemany · Issue #241 · oracle/python-cx_Oracle (original) (raw)

I have an issue where using executemany in python 2.7 with an integer in the very first row of the very first executemany, causes all subsequent rows to be inserted as integers. Sample:

create table test_bug (ID NUMBER(10,0), testnum NUMBER(20,2));

import cx_Oracle

connection = cx_Oracle.connect(...)
cursor = connection.cursor()
query = "INSERT INTO test_bug (id, testnum) VALUES (:id, :testnum)"
cursor.prepare(query)

cursor.executemany(None, [dict(id=1, testnum=14.95)])
cursor.executemany(None, [dict(id=2, testnum=10), dict(id=3, testnum=14.95)])
connection.commit()
connection.close()

connection = cx_Oracle.connect(...)
cursor = connection.cursor()
query = "INSERT INTO test_bug (id, testnum) VALUES (:id, :testnum)"
cursor.prepare(query)
cursor.executemany(None, [dict(id=4, testnum=10), dict(id=5, testnum=14.95)])
connection.commit()
connection.close()

Results:

  ID TESTNUM
---- -------
   1   14.95
   2      10
   3   14.95
   4      10
   5      14

I expected ID=5 to be 14.95, but it is 14. This does not happen in python 3, nor cx_Oracle 5.3.0. This appears to be related to the fix for #82 and #75

Answer the following questions:

  1. What is your version of Python? Is it 32-bit or 64-bit?
    Python 2.7.12
  2. What is your cx_Oracle version?
    6.2.0, 6.3.0, 7.0.0
  3. What error(s) you are seeing?
    Data incorrect
  4. What OS (and version) is Python executing on?
    Ubuntu 16.4
  5. What is your version of the Oracle client (e.g. Instant Client)? How was it installed? Where is it installed?
    I tried both Instant Client 11.2 and 12.2
  6. What is your Oracle Database version?
    Oracle 12c