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)
DECLARE
i INTEGER;
co_min_value CONSTANT SIMPLE_INTEGER := 1;
co_max_value CONSTANT SIMPLE_INTEGER := 10;
co_increment CONSTANT SIMPLE_INTEGER := 1;
BEGIN
i := co_min_value;
WHILE (i <= co_max_value)
LOOP
i := i + co_increment;
END LOOP;
LOOP
EXIT;
END LOOP;
FOR i IN co_min_value..co_max_value
LOOP
sys.dbms_output.put_line(i);
END LOOP;
FOR r_employee IN (SELECT last_name FROM employees)
LOOP
sys.dbms_output.put_line(r_employee.last_name);
END LOOP;
END;
/
Example (good)
DECLARE
i INTEGER;
co_min_value CONSTANT SIMPLE_INTEGER := 1;
co_max_value CONSTANT SIMPLE_INTEGER := 10;
co_increment CONSTANT SIMPLE_INTEGER := 1;
BEGIN
i := co_min_value;
<<while_loop>>
WHILE (i <= co_max_value)
LOOP
i := i + co_increment;
END LOOP while_loop;
<<basic_loop>>
LOOP
EXIT basic_loop;
END LOOP basic_loop;
<<for_loop>>
FOR i IN co_min_value..co_max_value
LOOP
sys.dbms_output.put_line(i);
END LOOP for_loop;
<<process_employees>>
FOR r_employee IN (SELECT last_name
FROM employees)
LOOP
sys.dbms_output.put_line(r_employee.last_name);
END LOOP process_employees;
END;
/