oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
307 stars 59 forks source link

cursor execute raise no_data_found without any exceptions #321

Closed Gepar closed 2 months ago

Gepar commented 2 months ago

Python 3.12.2 python-oracledb 2.1.1 Oracle 19.3.0.0.0 When cursor execute pl/sql block that raise no_data_found nothing happened.

import oracledb
conn = oracledb.connect("user", "password", "server")
cursor = conn.cursor()
-- no exception!
cursor.execute("begin raise no_data_found; end;")
-- exception
cursor.execute("begin raise CURSOR_ALREADY_OPEN; end;")
-- exception
cursor.execute("begin raise_application_error(-20000, 'user exception'); end;")

Maybe that's because sqlcode of no_data_found > 0. P.S. cx_oracle 8.3.0 will raise exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-01403: no data found
ORA-06512: at line 1
cjbj commented 2 months ago

python-oracledb Thick mode also raises the exception.

anthony-tuininga commented 2 months ago

I have pushed a patch that corrects this issue. If you are able to build from source you can verify that it works for you, too.

anthony-tuininga commented 2 months ago

This was included in version 2.1.2 which was just released.