Description
Hi,
1. What versions are you using?
Database version: Oracle Database 12c (12.1.0.2.0)
platform.platform: Windows-10-10.0.19044-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.10.9
oracledb.version: 1.2.1
cx_Oracle.version: 8.3.0
2. Is it an error or a hang or a crash?
error
3. What error(s) or behavior you are seeing?
When I am trying to insert an empty string into my database the input parameters after the empty string are getting shifted by one to the left. This leads to the following strange behavior:
- Data will be inserted into the wrong database field
- The types don't match (e.g. a string will be inserted into a number-field)
- The value is too large for the field.
Here is an example of case 3:
On Database:
CREATE TABLE tmp_table(
short_field VARCHAR2(1),
long_field VARCHAR2(50)
);
In Python:
data = [{
'SHORT_FIELD': '', # empty string
'LONG_FIELD': 'Loooong string'
}]
insert_statement = 'INSERT INTO tmp_table(SHORT_FIELD, LONG_FIELD) VALUES(:SHORT_FIELD, :LONG_FIELD)'
with get_database_connection() as connection:
with connection.cursor() as cursor:
cursor.executemany(insert_statement, data)
connection.commit()
After executing the python code I will get the following error:
oracledb.exceptions.DatabaseError: ORA-12899: value too large for column "TMP_TABLE"."SHORT_FIELD" (actual: 14, maximum: 1)
So the function executemany
tried to insert the wrong value ('Loooong string'
) into the field short_field
. Even though I defined a value for the field.
When executing the code with the function execute
I get the same error.
I also tried to insert an empty string with the python package cx_oracle
and it works.
4. Does your application call init_oracle_client()?
No
5. Include a runnable Python script that shows the problem.
see above
Thank you!