Skip to content

Commit b31518b

Browse files
Improve documentation.
1 parent 523f3b3 commit b31518b

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

doc/src/api_manual/cursor.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,20 @@ Cursor Methods
263263
available from a PL/SQL block or procedure without the use of OUT ref
264264
cursor parameters. The PL/SQL block or procedure opens the cursors and
265265
marks them for return to the client using the procedure
266-
dbms_sql.return_result. Cursors returned in this fashion should not be
267-
closed. They will be closed automatically by the parent cursor when it is
268-
closed. Closing the parent cursor will invalidate the cursors returned by
269-
this method.
266+
dbms_sql.return_result. In python-oracledb Thick mode, closing the parent
267+
cursor will result in the automatic closure of the implicit result set
268+
cursors. See :ref:`implicitresults`.
269+
270+
This method is only available for Oracle Database 12.1 (or later). For
271+
python-oracledb :ref:`Thick <enablingthick>` mode, Oracle Client 12.1 (or
272+
later) is additionally required.
270273

271274
.. note::
272275

273-
The DB API definition does not define this method and it is only
274-
available for Oracle Database 12.1 (both client and server must be at
275-
this level or higher). It is most like the DB API method nextset(), but
276-
unlike that method (which requires that the next result set overwrite
277-
the current result set), this method returns cursors which can be
278-
fetched independently of each other.
276+
The DB API definition does not define this method. It is most like the
277+
DB API method nextset(), but unlike that method (which requires that
278+
the next result set overwrite the current result set), this method
279+
returns cursors which can be fetched independently of each other.
279280

280281
.. method:: Cursor.parse(statement)
281282

doc/src/user_guide/appendix_b.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,22 @@ and UROWID database types. In python-oracledb Thick and Thin modes, comparison w
304304
the type ``oracledb.ROWID`` (defined in the Python DB API) will match both ROWID and
305305
UROWID database types.
306306

307+
.. _implicitresultsdiff:
308+
309+
Implicit Results in Thin and Thick Modes
310+
========================================
311+
312+
In python-oracledb Thick mode, the parent cursor that is used to get the
313+
:ref:`implicit results <implicitresults>` must remain open until all of the
314+
implicit result sets have been fetched or until the application no longer
315+
requires them. Closing the parent cursor before all the implicit result sets
316+
have been fetched will result in the automatic closure of the implicit result
317+
set cursors.
318+
319+
In python-oracledb Thin mode, there is no requirement to leave the parent
320+
cursor open when fetching implicit result sets. The parent cursor and implicit
321+
cursors are independently handled in Thin mode.
322+
307323
.. _stmtcaching:
308324

309325
Statement Caching in Thin and Thick Modes

doc/src/user_guide/plsql_execution.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ which may be much slower:
260260
break
261261
print(text_var.getvalue())
262262
263-
Implicit results
263+
.. _implicitresults:
264+
265+
Implicit Results
264266
----------------
265267

266268
Implicit results permit a Python program to consume cursors returned by a
@@ -297,6 +299,18 @@ Data from both the result sets are returned::
297299
(1000, 1, 'BOOKS')
298300
(2000, 2, 'FURNITURE')
299301

302+
When using python-oracledb Thick mode, you must leave the parent cursor open
303+
until all of the implicit result sets have been fetched or until your
304+
application no longer requires them. Closing the parent cursor before
305+
fetching all of the implicit result sets will result in the closure of the
306+
implicit result set cursors. If you try to fetch from an implicit result set
307+
after its parent cursor is closed, the following error will be thrown::
308+
309+
DPI-1039: statement was already closed
310+
311+
Note that the requirement mentioned above is not applicable for
312+
python-oracledb Thin mode. See :ref:`implicitresultsdiff`.
313+
300314
.. _ebr:
301315

302316
Edition-Based Redefinition (EBR)

doc/src/user_guide/tuning.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,15 @@ Avoiding Premature Prefetching
259259

260260
There are two cases that will benefit from setting ``prefetchrows`` to zero:
261261

262-
* When passing REF CURSORS *into* PL/SQL packages. Setting ``prefetchrows`` to
263-
0 can stop rows being prematurely (and silently) fetched into the
264-
python-oracledb internal buffer, making those rows unavailable to the PL/SQL
265-
code that receives the REF CURSOR.
262+
* When passing a python-oracledb cursor *into* PL/SQL. Setting
263+
``prefetchrows`` to 0 can stop rows being prematurely (and silently) fetched
264+
into the python-oracledb internal buffer, making those rows unavailable to
265+
the PL/SQL REF CURSOR parameter::
266+
267+
refcursor = connection.cursor()
268+
refcursor.prefetchrows = 0
269+
refcursor.execute("select ...")
270+
cursor.callproc("myproc", [refcursor])
266271

267272
* When querying a PL/SQL function that uses PIPE ROW to emit rows at
268273
intermittent intervals. By default, several rows needs to be emitted by the

0 commit comments

Comments
 (0)