Closed anthony-tuininga closed 6 months ago
I was table to replicate this. The protocol only allows for 65535 errors. If you exceed this value you get this error in thin mode. In thick mode you get invalid results (the number of batch errors is simply truncated by looking at the lowest 16 bits of the value) -- except when the number of batch errors is a multiple of 65535, in which case you get ORA-38902: errors in array DML exceed 65535
. As such, this is a bug in the database and will need to be fixed there. I will, however, correct the strange error in thin mode and ensure a more meaningful error is raised!
The issue can be avoided by always ensuring that you never send more than 65535 rows to the database at a time when using batch errors -- or by ensuring that the number of errors never exceeds 65535 in some other fashion.
A simple test case that demonstrates the problem:
create table issue_262 (
IntCol number(9) not null,
StringCol varchar2(50) not null,
constraint TestTempTable_pk primary key (IntCol)
);
with this Python script:
import oracledb
# oracledb.init_oracle_client()
conn = oracledb.connect("user/password@host/service_name")
cursor = conn.cursor()
data = [(1, None)] * (65537)
cursor.executemany("insert into issue_262 values (:1, :2)", data,
batcherrors=True)
errors = cursor.getbatcherrors()
print("found", len(errors), "batch errors")
I have pushed a patch that should correct this bug. If you are able to build from source you can verify that it works for you.
The patch has been included in version 2.0.0 which was just released.
Discussed in https://github.com/oracle/python-oracledb/discussions/261