-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.sql
74 lines (61 loc) · 1.29 KB
/
loop.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
SET serveroutput ON;
DECLARE
v_number NUMBER := 1;
v_sum NUMBER := 0;
BEGIN
WHILE v_number <= 10
LOOP
v_sum := v_sum + v_number;
dbms_output.put_line('v_sum = '||v_sum);
v_number := v_number + 1;
END LOOP;
END;
DECLARE
begin
for v_counter in 1..5 loop
-- v_counter := v_counter + 1;
dbms_output.put_line('v_counter = '||v_counter);
end loop;
end;
DECLARE
v_mum Number;
v_fact NUMBER;
begin
v_mum := &vv;
v_fact := 1;
for v_counter in 1..v_mum loop
v_fact := v_counter * v_fact;
end loop;
dbms_output.put_line('v_fact = '||v_fact);
end;
declare
v_counter1 number := 0;
v_counter2 number;
begin
while v_counter1 < 9 loop
dbms_output.put_line('v_counter1: '||v_counter1);
v_counter2 := 0;
loop
dbms_output.put_line('v_counter2: '||v_counter2);
v_counter2 := v_counter2 + 1;
exit when v_counter2 >= 2;
end loop;
v_counter1 := v_counter1 + 1;
end loop;
end;
declare
v_test number := 0;
begin
for i in 1..3 loop
dbms_output.put_line('Outer loop');
dbms_output.put_line('i='||i);
dbms_output.put_line('v_test='||v_test);
v_test := v_test + 1;
for j in 1..2 loop
dbms_output.put_line('Inner loop');
dbms_output.put_line('j='||j);
dbms_output.put_line('i='||i);
dbms_output.put_line('v_test = '||v_test);
end loop;
end loop;
end;