A reader, July 20, 2005 - 8:17 am UTC
OK, if someone innocent is supposed to ask a question, I will represent:
1)What's happening to the cursors, Guess: they are being Cached out by some internal LRU?
July 20, 2005 - 8:42 am UTC
no, it was to compare the nested begin/end block of Jonathan Gennick with calling the embedded function and observing that the scoping rules are different.
when we call the function 100 times, the cursor is closed each and every time.
if you have that big embedded block that defines a "sub scope" in the greater scope -- then they are not closed until that block exits
but Jonathan's conclusion is 100% dead on: if you open a cursor, close it - it is a bug in your code if you do not. Do not rely on this behavior, write the code right.
Ravi, July 20, 2005 - 9:04 am UTC
Any relation to PL/SQL's implicit 'Keep Cursor Open' phenomenon as described in
</code>
http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=166336.1 <code>
I do not have access to V$OPEN_CURSOR, but if I had opened a slightly different cursor in the procedure like
DECLARE
counts number(10):=0;
procedure p
is
cursor c is select sysdate+counts from dual;
d date;
begin
open c;
fetch c into d;
counts := counts+1;
end;
BEGIN
for I in 1 .. 1000
loop
p;
end loop;
END;
/
Would PL/SQL keep a 1000 cursors open now, but don't tell us, all in good intents, ofcourse?
July 20, 2005 - 12:38 pm UTC
the plsql cursor cache handles the cursors that are logically closed by plsql, but not physically closed.
Oracle 9i and 10G
Giridhar, July 20, 2005 - 9:56 am UTC
Hi Tom,
Thanks for your reply. I have one doubt.
Jonathan Gennick's article was on oracle 9i and your example is on oracle 10G. May i know whether you are able to reproduce this even in oracle 9i. As i dont have access to oracle 10G database, i am not able to test in 10G.
Regards,
Giridhar
A reader, July 20, 2005 - 11:12 am UTC
It works the same way in both 9i and 10g