Skip to content

Insert bind variables with large string value #146

Closed
@chichur

Description

@chichur

Hi @anthony-tuininga! I have similar problem #12 when i try insert large values use bind variables. Let' see code below.

System info
platform.platform: Windows-8.1-6.3.9600-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.10.3
oracledb.version: 1.2.1
Oracle Database: 19c Enterprise Edition Release 19.0.0.0.0 - Production

create test table:

create table x_test(name varchar2(10000 char), date d1);

Python code:

import oracledb
import datetime

dsn = f"*************************"
connection = oracledb.connect(dsn)
cursor = connection.cursor()

test_value = "x" * 9000
# if not this then raise ORA-01483: invalid length for DATE or NUMBER bind variable
cursor.setinputsizes(name=oracledb.DB_TYPE_CLOB)

# when operator in not 'begin end' block, code will be running without errors.
cursor.execute("""
            begin
                insert into x_test(name, d1) values(:name, :d);
            end;
        """,   name=test_value,
               d=datetime.datetime.now())

# this execute will be running without error 
# cursor.setinputsizes(name=oracledb.DB_TYPE_CLOB)
cursor.execute("""
            begin
                insert into x_test(name, d1) values(:name, sysdate);
            end;
        """,   name=test_value))
connection.commit()
connection.close()

Traceback:

Traceback (most recent call last):
  File "C:\test\bug.py", line 11, in <module>
    cursor.execute("""
  File "C:\test\venv\lib\site-packages\oracledb\cursor.py", line 378, in execute
    impl.execute(self)
  File "src\oracledb\impl/thin/cursor.pyx", line 133, in oracledb.thin_impl.ThinCursorImpl.execute
  File "src\oracledb\impl/thin/protocol.pyx", line 383, in oracledb.thin_impl.Protocol._process_single_message
  File "src\oracledb\impl/thin/protocol.pyx", line 384, in oracledb.thin_impl.Protocol._process_single_message
  File "src\oracledb\impl/thin/protocol.pyx", line 377, in oracledb.thin_impl.Protocol._process_message
oracledb.exceptions.DatabaseError: ORA-01483: неверная длина для переменных привязки типов DATE или NUMBER

Process finished with exit code 1

P.S. With cx_Oracle all succeed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions