G-2170: Never overload variables.
Major
Reliability
Reason
The readability of your code will be higher when you do not overload variables.
Example (bad)
BEGIN
<<main>>
DECLARE
co_main CONSTANT user_objects.object_name%TYPE := 'test_main';
co_sub CONSTANT user_objects.object_name%TYPE := 'test_sub';
co_sep CONSTANT user_objects.object_name%TYPE := ' - ';
l_variable user_objects.object_name%TYPE := co_main;
BEGIN
<<sub>>
DECLARE
l_variable user_objects.object_name%TYPE := co_sub;
BEGIN
sys.dbms_output.put_line(l_variable || co_sep || main.l_variable);
END sub;
END main;
END;
/
Example (good)
BEGIN
<<main>>
DECLARE
co_main CONSTANT user_objects.object_name%TYPE := 'test_main';
co_sub CONSTANT user_objects.object_name%TYPE := 'test_sub';
co_sep CONSTANT user_objects.object_name%TYPE := ' - ';
l_main_variable user_objects.object_name%TYPE := co_main;
BEGIN
<<sub>>
DECLARE
l_sub_variable user_objects.object_name%TYPE := co_sub;
BEGIN
sys.dbms_output.put_line(l_sub_variable || co_sep || l_main_variable);
END sub;
END main;
END;
/