Link to home
Start Free TrialLog in
Avatar of ratliffjm
ratliffjmFlag for United States of America

asked on

ADD 5 TO COUNTER IN FOR LOOP

How can I increment  the count in a variable in the loop instead of codeing the actual numbers for the count such as (4,9,14,19,24).  In other words, I just want to add 5 to the counter beginning with record number 4 in the loop.  There can be up to 24  records in the loop.    

This is an oracle table.  I'm using PL/SQL.
See attached code.  



v_count := 0
 
for c1 rec in c1  loop
 v_count := v_count + 1;
 
if v_count in (4,9,14,19,24)  then 
  put_line (l_file,'TEST1');
end if;
 if v_count  in (5,10,15,20) then
  put_line(l_file,TEST2);
end if;
if v_count in (6,11,16,21)
 put_line(l_file,TEST2);
end if;
 
end loop;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ratliffjm

ASKER

Thanks.   I will test the code when I'm at the office tomorrow morning.
Thanks
Avatar of Sean Stuber
Sean Stuber

glad I could help