Home
Nested blocks should be labeled
Rule description
- Nested blocks should be labeled
Non-compliant Code Example
DECLARE first_name VARCHAR2(25); customer_id NUMBER(6) := 120; BEGIN <<get_customer_name>> SELECT FIRSTNAME INTO first_name FROM CUSTOMERS WHERE Id = customer_id; BEGIN --Non compliant code (Nested block is not labeled) DBMS_OUTPUT.PUT_LINE (first_name); customer_id := customer_id + 1; IF customer_id < 200 THEN GOTO get_customer_name; END IF; END; END;
Compliant Code Example
DECLARE first_name VARCHAR2(25); customer_id NUMBER(6) := 120; BEGIN <<get_customer_name>> SELECT FIRSTNAME INTO first_name FROM CUSTOMERS WHERE Id = customer_id; <<get_customer_name_inner>> BEGIN --Compliant code (Nested block is labeled) DBMS_OUTPUT.PUT_LINE (first_name); customer_id := customer_id + 1; IF customer_id < 200 THEN GOTO get_customer_name; END IF; END; END;