Skip to content

Commit 3df1328

Browse files
Error "DPY-2068: scroll operation is not supported on a non-scrollable
cursor" is now raised when using the Cursor.scroll() method on a non-scrollable cursor.
1 parent 8af6668 commit 3df1328

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Common Changes
3434
#) Fixed bug that caused ``ORA-03137: malformed TTC packet from client
3535
rejected`` exception to be raised when attempting to call
3636
:meth:`Cursor.parse()` on a scrollable cursor.
37+
#) Error ``DPY-2068: scroll operation is not supported on a non-scrollable
38+
cursor`` is now raised when using :meth:`Cursor.scroll()` method on a
39+
non-scrollable cursor.
3740

3841

3942
oracledb `3.4.0 <https://github.com/oracle/python-oracledb/compare/v3.3.0...v3.4.0>`__ (October 2025)

src/oracledb/cursor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,8 @@ def scroll(self, value: int = 0, mode: str = "relative") -> None:
10341034
scroll operation would position the cursor outside of the result set.
10351035
"""
10361036
self._verify_open()
1037+
if not self._impl.scrollable:
1038+
errors._raise_err(errors.ERR_SCROLL_NOT_SUPPORTED)
10371039
self._impl.scroll(self, value, mode)
10381040

10391041

@@ -1366,4 +1368,6 @@ async def scroll(self, value: int = 0, mode: str = "relative") -> None:
13661368
scroll operation would position the cursor outside of the result set.
13671369
"""
13681370
self._verify_open()
1371+
if not self._impl.scrollable:
1372+
errors._raise_err(errors.ERR_SCROLL_NOT_SUPPORTED)
13691373
await self._impl.scroll(self, value, mode)

src/oracledb/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def _raise_not_supported(feature: str) -> None:
291291
ERR_ARROW_SPARSE_VECTOR_NOT_ALLOWED = 2065
292292
ERR_EMPTY_STATEMENT = 2066
293293
ERR_WRONG_DIRECT_PATH_DATA_TYPE = 2067
294+
ERR_SCROLL_NOT_SUPPORTED = 2068
294295

295296
# error numbers that result in NotSupportedError
296297
ERR_TIME_NOT_SUPPORTED = 3000
@@ -894,6 +895,9 @@ def _raise_not_supported(feature: str) -> None:
894895
ERR_PYTHON_VALUE_NOT_SUPPORTED: (
895896
'Python value of type "{type_name}" is not supported'
896897
),
898+
ERR_SCROLL_NOT_SUPPORTED: (
899+
"scroll operation is not supported on a non-scrollable cursor"
900+
),
897901
ERR_SCROLL_OUT_OF_RESULT_SET: (
898902
"scroll operation would go out of the result set"
899903
),

tests/test_4200_cursor_scrollable.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,11 @@ def test_4216(conn):
265265
cursor.scroll(mode="last")
266266
(fetched_value,) = cursor.fetchone()
267267
assert fetched_value == base_value + 3
268+
269+
270+
def test_4217(conn, test_env):
271+
"4217 - test calling scroll() on a non-scrollable cursor"
272+
cursor = conn.cursor()
273+
cursor.execute("select NumberCol from TestNumbers order by IntCol")
274+
with test_env.assert_raises_full_code("DPY-2068"):
275+
cursor.scroll(mode="first")

tests/test_8600_cursor_scrollable_async.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,11 @@ async def test_8616(async_conn):
268268
await cursor.scroll(mode="last")
269269
(fetched_value,) = await cursor.fetchone()
270270
assert fetched_value == base_value + 3
271+
272+
273+
async def test_8617(async_conn, test_env):
274+
"8717 - test calling scroll() on a non-scrollable cursor"
275+
cursor = async_conn.cursor()
276+
await cursor.execute("select NumberCol from TestNumbers order by IntCol")
277+
with test_env.assert_raises_full_code("DPY-2068"):
278+
await cursor.scroll(mode="first")

0 commit comments

Comments
 (0)