You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# G-4365: Never use unconditional CONTINUE or EXIT in a loop.
2
+
3
+
!!! warning "Major"
4
+
Maintainability, Testability
5
+
6
+
## Reason
7
+
8
+
An unconditional `continue` is either redundant (a `continue` as the last statement before the end of the loop) or causes dead code. An unconditional `exit` causes no looping and may cause dead code as well. If `continue` or `exit` is needed, it should always have a condition.
9
+
10
+
## Example (bad)
11
+
12
+
```sql
13
+
begin
14
+
<<process_employees>>
15
+
loop
16
+
my_package.some_processing();
17
+
18
+
continue process_employees;
19
+
20
+
my_package.some_further_processing(); -- Dead code
21
+
end loop process_employees;
22
+
end;
23
+
/
24
+
```
25
+
26
+
## Example (good)
27
+
28
+
```sql
29
+
declare
30
+
co_first_year constant pls_integer :=1900;
31
+
begin
32
+
<<process_employees>>
33
+
loop
34
+
my_package.some_processing();
35
+
36
+
continue process_employees when extract(year fromsysdate) > co_first_year;
0 commit comments