Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A loop inside a loop

MaxNov 10 2008 — edited Nov 11 2008
DB version:10g release 2

I am currently learning the basics of loop in PL/SQL. I understand normal loops like the one below where a rec (a PL/SQL RECORD) stores all the rows in emp table and emp_dtl.emp_daily_track_nbr is getting updated with sysdate in MMDDYYYY format within a loop.

But can anyone show me a scenario of where a loop inside a loop is used? Is a loop inside a loop efficient?


 --looping through emp rows
 FOR i IN rec.emp.First..rec.emp.COUNT LOOP
        BEGIN

update emp_dtl set 
        emp_daily_track_nbr = to_char(sysdate,'MMDDYYYY')
                where emp_dtl.emp_id = rec.empno(i);
                
 end loop;
 end.
 
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 9 2008
Added on Nov 10 2008
11 comments
2,245 views