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
18
19 | 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)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | 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;
/
|