Thursday, 24 May 2012

What is a cursor FOR loop and how does it differ from an explicit cursor? | PL SQL

 Cursor FOR loop is a shortcut to use explicit cursors. It does not require explicit opening, fetching, and closing of the cursor. In other words, the cursor FOR loop implicitly opens the cursor, fetches the record, and closes the cursor. In the cursor FOR loop, the cursor is defined and its attributes are checked within the processing of the FOR loop. The records are also implicitly defined within the loop, as shown in the following code:
It is also possible to use a cursor FOR loop with a sub query, where the cursor name is not defined. In this case,
the attributes of the cursor cannot be checked as no explicit cursor name is defined.