The Cursor Loop

I continue to share some information I learned during my instructor led training at Oracle. A random tidbit is the CURRENT_DATE function. It operates like the SYSDATE that you know and love. However it automatically adjusts for your local time. How do you like that?

FOR LOOPs that iterate through a cursor as called Cursor Loops. The cursor active set is like the result set in Java. The query for your cursor takes place when you open the cursor. Note that the Cursor Loop does not perform any better than manually opening a cursor and fetching rows. A good thing about the Cursor Loop is that it automatically closes the cursor even if an exception is raised.

It is a good design to tie the cursor record type to the cursor by means of the %ROWTYPE. When you have fetched some records out of a cursor, the total number of records you have fetched so far is stored in the %ROWCOUNT variable. That's it for now. Next time I will probably talk a bit about FOR UPDATE OF and WHERE CURRENT OF. See you then.