Skip to content

Commit

Permalink
Fixed bug that prevented error "ORA-01403: no data found" from being
Browse files Browse the repository at this point in the history
raised when executing a PL/SQL block (#321).
  • Loading branch information
anthony-tuininga committed Apr 11, 2024
1 parent 7725474 commit c1f7361
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ oracledb 2.1.2 (TBD)
Thin Mode Changes
+++++++++++++++++

#) Fixed bug that prevented error ``ORA-01403: no data found`` from being
raised when executing a PL/SQL block
(`issue 321 <https://github.com/oracle/python-oracledb/issues/321>`__).

Thick Mode Changes
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion src/oracledb/impl/thin/messages.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ cdef class MessageWithData(Message):
cursor_impl._batcherrors = self.error_info.batcherrors
if self.batcherrors and cursor_impl._batcherrors is None:
cursor_impl._batcherrors = []
if self.error_info.num == TNS_ERR_NO_DATA_FOUND:
if self.error_info.num == TNS_ERR_NO_DATA_FOUND and self.in_fetch:
self.error_info.num = 0
cursor_impl._more_rows_to_fetch = False
cursor_impl._last_row_index = 0
Expand Down
5 changes: 5 additions & 0 deletions tests/test_3900_cursor_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ def test_3934(self):
self.cursor.execute("begin null; end;")
self.assertEqual(self.cursor.rowcount, 0)

def test_3935(self):
"3935 - test raising no_data_found in PL/SQL"
with self.assertRaisesFullCode("ORA-01403"):
self.cursor.execute("begin raise no_data_found; end;")


if __name__ == "__main__":
test_env.run_test_cases()
5 changes: 5 additions & 0 deletions tests/test_5400_cursor_execute_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ async def test_5435(self):
row = await self.cursor.fetchone()
self.assertEqual(row, tuple(values))

async def test_5436(self):
"5436 - test raising no_data_found in PL/SQL"
with self.assertRaisesFullCode("ORA-01403"):
await self.cursor.execute("begin raise no_data_found; end;")


if __name__ == "__main__":
test_env.run_test_cases()

0 comments on commit c1f7361

Please sign in to comment.