From c1f736128a5300bcc119b000ff1d2530a5a21f26 Mon Sep 17 00:00:00 2001 From: Anthony Tuininga Date: Thu, 11 Apr 2024 10:21:17 -0600 Subject: [PATCH] Fixed bug that prevented error "ORA-01403: no data found" from being raised when executing a PL/SQL block (#321). --- doc/src/release_notes.rst | 4 ++++ src/oracledb/impl/thin/messages.pyx | 2 +- tests/test_3900_cursor_execute.py | 5 +++++ tests/test_5400_cursor_execute_async.py | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 6c888173..eb9a2af3 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -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 `__). + Thick Mode Changes ++++++++++++++++++ diff --git a/src/oracledb/impl/thin/messages.pyx b/src/oracledb/impl/thin/messages.pyx index 91910e18..7d27b6ae 100644 --- a/src/oracledb/impl/thin/messages.pyx +++ b/src/oracledb/impl/thin/messages.pyx @@ -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 diff --git a/tests/test_3900_cursor_execute.py b/tests/test_3900_cursor_execute.py index 166c7300..249f3bcd 100644 --- a/tests/test_3900_cursor_execute.py +++ b/tests/test_3900_cursor_execute.py @@ -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() diff --git a/tests/test_5400_cursor_execute_async.py b/tests/test_5400_cursor_execute_async.py index 68ac0b98..3026af78 100644 --- a/tests/test_5400_cursor_execute_async.py +++ b/tests/test_5400_cursor_execute_async.py @@ -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()