Home

Loop start and end labels should match

Rule description

  • Loop start and end labels should match

 

Non-compliant Code Example

DECLARE 
   id customers.id%type; 
   name customer.name%type; 
   address customers.address%type; 
   CURSOR customers_c is 
      SELECT id, name, address FROM customers; 
BEGIN 
   OPEN customers_c; 
   <<INNER_LOOP>>               --Non compliant code (Loop start and end labels are not matching)
   LOOP 
   FETCH customers_c into id, name, address; 
      EXIT WHEN customers_c%notfound; 
      dbms_output.put_line(id || ' ' || name || ' ' || address); 
   END LOOP INNERONE_LOOP; 
   CLOSE customers_c; 
END; 

Compliant Code Example

DECLARE 
   id customers.id%type; 
   name customer.name%type; 
   address customers.address%type; 
   CURSOR customers_c is 
      SELECT id, name, address FROM customers; 
BEGIN 
   OPEN customers_c; 
   <<INNER_LOOP>>           --Compliant code (Loop start and end labels are matching)
   LOOP 
   FETCH customers_c into id, name, address; 
      EXIT WHEN customers_c%notfound; 
      dbms_output.put_line(id || ' ' || name || ' ' || address); 
   END LOOP INNER_LOOP; 
   CLOSE customers_c; 
END; 
Visual Expert 2020
 VEPLSQLRULE22