Home

Variables Declared multiple times in nested scope

Rule description

  • Variables should be declared only once in a scope

 

Non-compliant Code Example

DECLARE
  CURSOR curs_customer(customer_name VARCHAR2) RETURN customer%ROWTYPE;         --Non compliant code (Variable declare more than one time)

  CURSOR curs_customer(customer_name VARCHAR2) RETURN customer%ROWTYPE IS SELECT * FROM CUSTOMERS WHERE name = customer_name; 
BEGIN
  NULL;
END;

Compliant Code Example

DECLARE
  CURSOR curs_customer1(customer_name VARCHAR2) RETURN customer%ROWTYPE;        --Compliant code (Variable declare once)

  CURSOR curs_customer2(customer_name VARCHAR2) RETURN customer%ROWTYPE IS SELECT * FROM CUSTOMERS WHERE name = customer_name; 
BEGIN
  NULL;
END;
Visual Expert 2020
 VEPLSQLRULE4