The loop index has the datatype of ROWTYPE which internally returns the cursor and also opens the same later. An implicit creation of the loop index is being done while using cursor for loop which helps to retrieve each and every row from the cursor and the best part is that there is no need to manage the cycle of execution involving open, fetch and close steps. Hadoop, Data Science, Statistics & others Functions of Cursor LoopĮach cursor is associated with a certain query and for all the records retrieved from that query, the cursor loop does the execution of the body of the loop once for each record. In this article, we will have a look at the syntax, working and implementation of the cursor loops in PL/ SQL along with the help of certain examples.
That is why, the use of cursor for loop is very efficient as none of the value needs to be maintained for looping out and all the execution cycle containing the opening, closing, and fetching of the index or cursor that was in traditional integer for loops is maintained internally automatically by cursor loop. This type of cursor for loop is a great extension of the traditional type of numeric for loop in which an integer was used to store a value that will be incremented or decremented on each loop traversal.įurther, the manipulation and modification of the integer was also the extra work added.
The FOR LOOP is used by the cursor for carrying out the repetitive task of processing the records retrieved from the cursor reference.
PL/SQL cursor loop statement is used for fetching and processing each and every record one by one which is referred to by a cursor.