Skip to content

Insert bind variables with large string value #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chichur opened this issue Feb 15, 2023 · 4 comments
Closed

Insert bind variables with large string value #146

chichur opened this issue Feb 15, 2023 · 4 comments
Labels
bug Something isn't working patch available

Comments

@chichur
Copy link

chichur commented Feb 15, 2023

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

@cjbj
Copy link
Member

cjbj commented Feb 20, 2023

Thanks for reporting this.

@anthony-tuininga
Copy link
Member

I have pushed a patch that should correct this issue and added a relevant test case. If you are able to build from source you can verify that it corrects your issue as well.

anthony-tuininga added a commit that referenced this issue Mar 21, 2023

Verified

This commit was signed with the committer’s verified signature.
lforst Luca Forstner
potentially exceed the 32767 byte limit but the actual value bound does
not (#146).
@anthony-tuininga
Copy link
Member

This has been included in version 1.3.0 which was just released.

@chichur
Copy link
Author

chichur commented Apr 3, 2023

Thanks it's work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working patch available
Projects
None yet
Development

No branches or pull requests

3 participants