G-4320: Always label your loops.

Minor

Maintainability

Reason

It's a good alternative for comments to indicate the start and end of a named loop processing.

Example (bad)

 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
declare
   i integer;
   k_min_value constant simple_integer := 1;
   k_max_value constant simple_integer := 10;
   k_increment constant simple_integer := 1;
begin
   i := k_min_value;
   while (i <= k_max_value) 
   loop 
      i := i + k_increment; 
   end loop;

   loop 
      exit;
   end loop;

   for i in k_min_value..k_max_value
   loop 
      sys.dbms_output.put_line(i);
   end loop;

   for r_employee in (select last_name from employee)
   loop
      sys.dbms_output.put_line(r_employee.last_name);
   end loop;   
end;
/

Example (good)

 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
declare
   i integer;
   k_min_value constant simple_integer := 1;
   k_max_value constant simple_integer := 10;
   k_increment constant simple_integer := 1;
begin
   i := k_min_value;
   <<while_loop>>
   while (i <= k_max_value) 
   loop 
      i := i + k_increment; 
   end loop while_loop;

   <<basic_loop>>
   loop 
      exit basic_loop;
   end loop basic_loop;

   <<for_loop>>
   for i in k_min_value..k_max_value
   loop 
      sys.dbms_output.put_line(i);
   end loop for_loop;

   <<process_employees>>
   for r_employee in (select last_name
                        from employee)
   loop
      sys.dbms_output.put_line(r_employee.last_name);
   end loop process_employees;
end;
/