-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterative_processing.sql
More file actions
70 lines (51 loc) · 1.04 KB
/
iterative_processing.sql
File metadata and controls
70 lines (51 loc) · 1.04 KB
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
SET SERVEROUTPUT ON;
-- Basic Loop
DECLARE
l_counter NUMBER := 0;
BEGIN
LOOP
l_counter := l_counter + 1;
IF l_counter > 5 THEN
EXIT;
END IF;
DBMS_OUTPUT.PUT_LINE(l_counter);
END LOOP;
END;
-- FOR LOOP
BEGIN
FOR l_counter IN 1..5 LOOP
DBMS_OUTPUT.PUT_LINE(l_counter);
END LOOP;
END;
-- REVERSE FOR LOOP
BEGIN
FOR l_counter IN REVERSE 1..5 LOOP
DBMS_OUTPUT.PUT_LINE(l_counter);
END LOOP;
END;
-- WHILE LOOP
DECLARE
l_counter NUMBER := 1;
BEGIN
WHILE l_counter <= 5 LOOP
DBMS_OUTPUT.PUT_LINE('Counter: ' || l_counter);
l_counter := l_counter + 1;
EXIT WHEN l_counter = 3;
END LOOP;
END;
-- Continue
BEGIN
FOR n_index IN 1..10 LOOP
IF MOD(n_index, 2) = 1 THEN
CONTINUE;
END IF;
DBMS_OUTPUT.PUT_LINE(n_index);
END LOOP;
END;
-- Continue When
BEGIN
FOR n_index IN 1..10 LOOP
CONTINUE WHEN MOD(n_index,2)=0;
DBMS_OUTPUT.PUT_LINE(n_index);
END LOOP;
END;