Skip to content

Commit c1f7361

Browse files
Fixed bug that prevented error "ORA-01403: no data found" from being
raised when executing a PL/SQL block (#321).
1 parent 7725474 commit c1f7361

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

doc/src/release_notes.rst

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ oracledb 2.1.2 (TBD)
1313
Thin Mode Changes
1414
+++++++++++++++++
1515

16+
#) Fixed bug that prevented error ``ORA-01403: no data found`` from being
17+
raised when executing a PL/SQL block
18+
(`issue 321 <https://github.com/oracle/python-oracledb/issues/321>`__).
19+
1620
Thick Mode Changes
1721
++++++++++++++++++
1822

src/oracledb/impl/thin/messages.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ cdef class MessageWithData(Message):
774774
cursor_impl._batcherrors = self.error_info.batcherrors
775775
if self.batcherrors and cursor_impl._batcherrors is None:
776776
cursor_impl._batcherrors = []
777-
if self.error_info.num == TNS_ERR_NO_DATA_FOUND:
777+
if self.error_info.num == TNS_ERR_NO_DATA_FOUND and self.in_fetch:
778778
self.error_info.num = 0
779779
cursor_impl._more_rows_to_fetch = False
780780
cursor_impl._last_row_index = 0

tests/test_3900_cursor_execute.py

+5
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,11 @@ def test_3934(self):
554554
self.cursor.execute("begin null; end;")
555555
self.assertEqual(self.cursor.rowcount, 0)
556556

557+
def test_3935(self):
558+
"3935 - test raising no_data_found in PL/SQL"
559+
with self.assertRaisesFullCode("ORA-01403"):
560+
self.cursor.execute("begin raise no_data_found; end;")
561+
557562

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

tests/test_5400_cursor_execute_async.py

+5
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,11 @@ async def test_5435(self):
591591
row = await self.cursor.fetchone()
592592
self.assertEqual(row, tuple(values))
593593

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

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

0 commit comments

Comments
 (0)