G-1030: Avoid defining variables that are not used.
Minor
Efficiency, Maintainability
Reason
Unused variables decrease the maintainability and readability of your code.
Example (bad)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | create or replace package body my_package is procedure my_proc is l_last_name employee.last_name%type; l_first_name employee.first_name%type; k_department_id constant department.department_id%type := 10; e_good exception; begin select e.last_name into l_last_name from employee e where e.department_id = k_department_id; exception when no_data_found then null; -- handle_no_data_found; when too_many_rows then null; -- handle_too_many_rows; end my_proc; end my_package; / |
Example (good)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | create or replace package body my_package is procedure my_proc is l_last_name employee.last_name%type; k_department_id constant department.department_id%type := 10; e_good exception; begin select e.last_name into l_last_name from employee e where e.department_id = k_department_id; raise e_good; exception when no_data_found then null; -- handle_no_data_found; when too_many_rows then null; -- handle_too_many_rows; end my_proc; end my_package; / |