Close cursor after for loop?

I read your answer regarding memory links. I know that when you explicitly open a cursor (OPEN c1; for example), you should close the cursor explicitly also (CLOSE c1). Do you also need to close the cursor after a for loop? For example:
 
FOR i in c1 LOOP
...
END LOOP;
Thanks.

    Requires Free Membership to View

You can close the cursor at any time you are done with it. However, it is good programming practice to open the cursor right before the loop that processes it and then close the cursor when the loop finishes. The cursor is only used in the loop (after all, you're looping through the cursor's rowset) so if you do not close it right after the loop, you might forget to close it later.

This was first published in April 2006

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.