Python - cx_oracle Update throws ORA-01036

Viewed 19

our UPDATE statement looks like this:

upd = """UPDATE prices \
         SET pre_after_price = :1, \
             volume = :2, \
             pre_after_updated = SYSDATE + INTERVAL '1' HOUR \
         WHERE ticker = :3"""

Then, the actual code is this:

cursor.execute(upd,([pre_after_price, volume, ticker]))

But rather, we get this error:

ORA-01036: illegal variable name/number
dpiStmt_bindByPos: bind by position

Is there something we are doing wrong?

1 Answers

You can issue this statement first:

cursor.prepare(upd)
print("bind names:", cursor.bindnames())

That should tell you which bind names are expected!

If you use the new thin mode of python-oracledb (replacement for cx_Oracle) cursor.execute() provides more useful information about what is missing or incorrect. If you're not aware of the new driver I would recommend checking it out! https://oracle.github.io/python-oracledb/

Related