rules repository

G-2170

🆓
Warning

Never overload variables.

Reason

The readability of your code will be higher when you do not overload variables.

Example

Non-Compliant Example

begin
   <<main>>
   declare
      l_variable user_objects.object_name%type := 'test_main';
   begin
      <<sub>>
      declare
         l_variable user_objects.object_name%type := 'test_sub';
      begin
         sys.dbms_output.put_line(l_variable
            || '-'
            || main.l_variable);
      end sub;
   end main;
end;
/
Issues
LineColumnMessage
810Overloaded variable l_variable.

Compliant Solution - ★★★★★

begin
   <<main>>
   declare
      l_main_variable user_objects.object_name%type := 'test_main';
   begin
      <<sub>>
      declare
         l_sub_variable user_objects.object_name%type := 'test_sub';
      begin
         sys.dbms_output.put_line(l_sub_variable
            || '-'
            || l_main_variable);
      end sub;
   end main;
end;
/

References