Home
LOOP ... END LOOP; constructs should be avoided
Rule description
- LOOP ... END LOOP; constructs should be avoided
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>>
LOOP --Non compliant code (Constructs of LOOP and END LOOP should be avoided)
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;
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; --Compliant code
FETCH customers_c into id, name, address;
EXIT WHEN customers_c%notfound;
dbms_output.put_line(id || ' ' || name || ' ' || address);
CLOSE customers_c;
END;