DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: CLOSE-ing REF CURSORs?

  1. #1
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    When using CURSORS, it was always important to have an EXCEPTION clause that would close the cursor and raise the error if anything went wrong. This was necessary, based on my understanding, because if the proc exited without closing the cursor, the OPEN CURSOR count would not be decremented and eventually this would cause a problem.

    The question is: Do REF CURSORs suffer the same fate?

    So, if I declare a local variable within a proc as a REF CURSOR (type), then I OPEN it for something, do I even need to CLOSE it at all?

    I am personally of the opinion that I do not. I believe that the cursor will 'close' when it goes out of scope, the resultset will be released and there will be no ill-effects.

    Does anyone have any information for or against this position?

    Thanks,

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Acording to Tom Kyte (and I've never read anything from him that would make me doubt in what he says) you should treat ref cursors just like normal cursors, ie close them when you are done with them.

    http://asktom.oracle.com/pls/ask/f?p...:1606716582692

    http://asktom.oracle.com/pls/ask/f?p...:1928887333955

    http://asktom.oracle.com/pls/ask/f?p...:1401210350504

    [Edited by jmodic on 01-31-2002 at 05:46 PM]
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Excellent info as always Jurij.

    I should have searched Tom's site myself (bad programmer!)

    Thanks,

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width