1DECLARE @cnt INT = 0;
2
3WHILE @cnt < cnt_total
4BEGIN
5 {...statements...}
6 SET @cnt = @cnt + 1;
7END;
1/*
2For loop in sql
3*/
4Example:
5DECLARE
6 a number(2);
7BEGIN
8 FOR a in 10 .. 20 LOOP
9 dbms_output.put_line('value of a: ' || a);
10 END LOOP;
11END;
12/
13
14
15Output:
16value of a: 10
17value of a: 11
18value of a: 12
19value of a: 13
20value of a: 14
21value of a: 15
22value of a: 16
23value of a: 17
24value of a: 18
25value of a: 19
26value of a: 20