Cursor Lifetime in Oracle

If I open the cursor and forget to close it, how long will the pointer exist in Oracle?

Are there any settings for setting the cursor lifetime?

+5
source share
2 answers

Like DCookie's answer:

General cursor lifetime pattern

OPEN 
BIND
EXECUTE
FETCH...FETCH...FETCH
BIND
EXECUTE
FETCH...FETCH...FETCH
...
CLOSE

This cursor can be reused by binding fresh variables to it and re-executing it.

PL / SQL will also support session-level cursor caches to avoid the overhead of re-opening the cursor recently closed. Thus, the cursor that you programmatically close can remain open. Oracle will cover them backstage if necessary.

, . , :

DECLARE
  CURSOR c_1 IS SELECT ....;
BEGIN
  OPEN c_1;
  FETCH c_1 INTO...;
END;

, , c_1 ( ) . , , "CLOSE c_1;" . , .

(, PL/SQL ref), , DBMS_SESSION.MODIFY_PACKAGE_STATE (DBMS_SESSION.FREE_ALL_RESOURCES);

+4

, , .

, , ; -)

, , , . , .
+2

All Articles