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)
CREATE OR REPLACE PACKAGE BODY my_package IS
PROCEDURE my_proc IS
l_last_name employees.last_name%TYPE;
l_first_name employees.first_name%TYPE;
co_department_id CONSTANT departments.department_id%TYPE := 10;
e_good EXCEPTION;
BEGIN
SELECT e.last_name
INTO l_last_name
FROM employees e
WHERE e.department_id = co_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)
CREATE OR REPLACE PACKAGE BODY my_package IS
PROCEDURE my_proc IS
l_last_name employees.last_name%TYPE;
co_department_id CONSTANT departments.department_id%TYPE := 10;
e_good EXCEPTION;
BEGIN
SELECT e.last_name
INTO l_last_name
FROM employees e
WHERE e.department_id = co_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;
/