Skip to content

DPY-4010 python-oracledb misinterpreting string literal as BIND variable #208

@mikemulhearn

Description

@mikemulhearn
  1. What versions are you using?
python-oracledb version: 1.3.2

platform.platform: Windows-10-10.0.14393-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.10.7

oracledb.__version__: 1.3.2
  1. Is it an error or a hang or a crash?

Error

  1. What error(s) or behavior you are seeing?

The library appears to be incorrectly interpreting a query that works as-is in SQL developer. One of the sub-queries within a decode function in the SELECT clause containing a string with a colon (enclosed between single quotes) appears to be attempting to be interpreted as a BIND variable, when it is only a hardcoded string.

Affected Clause:

DECODE((SELECT  1 
			FROM argus_app.case_classifications cc,
			     argus_app.lm_case_classification lcc
		   WHERE cc.classification_id = lcc.classification_id
		     AND UPPER(lcc.description) = 'CONSENT TO FU GRANTED'
			 AND cc.deleted is null
			 AND lcc.deleted is null
			 AND cc.case_id = cmas.case_id),1,'Yes',
		  (SELECT  1 
			FROM argus_app.case_classifications cc,
			     argus_app.lm_case_classification lcc
		   WHERE cc.classification_id = lcc.classification_id
		     AND UPPER(lcc.description) LIKE 'FU: CONSENT GRANTED'
			 AND cc.deleted is null
			 AND lcc.deleted is null
			 AND cc.case_id = cmas.case_id),1,'Yes') "FU_POSSIBLE"

Full Query:

https://gist.github.com/mikemulhearn/3fa6ab5a6a4636284d637ee6b5f305d8

Python Command (standard query execution):

conn = oracledb.connect(user=username, password=password, dsn=dsn_tns, threaded=True)
curs = conn.cursor()
curs.execute(query)

Error:

DPY-4010: a bind variable replacement value for placeholder ":CONSENT" was not provided
Traceback (most recent call last):
  File "C:\Users\mm3fa7782\PycharmProjects\oracle_extract\oracle_extract.py", line 286, in oracle_plsql_extract
    curs.execute(cnt_query)
  File "C:\Users\mm3fa7782\PycharmProjects\oracle_extract\venv\lib\site-packages\oracledb\cursor.py", line 378, in execute
    impl.execute(self)
  File "src\oracledb\impl/thin/cursor.pyx", line 135, in oracledb.thin_impl.ThinCursorImpl.execute
  File "src\oracledb\impl/thin/cursor.pyx", line 128, in oracledb.thin_impl.ThinCursorImpl._preprocess_execute
  File "C:\Users\mm3fa7782\PycharmProjects\oracle_extract\venv\lib\site-packages\oracledb\errors.py", line 118, in _raise_err
    raise exc_type(_Error(message)) from cause
oracledb.exceptions.DatabaseError: DPY-4010: a bind variable replacement value for placeholder ":CONSENT" was not provided
  1. Does your application call init_oracle_client()?

Yes, I have attempted to use both the Thick client (default) and the Thin client, with the same result.

  1. Include a runnable Python script that shows the problem.

The above full query should be able to run through the python-oracledb query interpreter to show that it is finding a BIND variable that should not exist. Due to the complexity of the above query, I would prefer not to provide a schema to create the example here, if at all possible. This error appears to be happening by the statement interpreter and hopefully should not need a database to query.

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