G-2145: Never self-assign a variable.
Reason
There is no reason to assign a variable to itself. It is either a redundant statement that should be removed, or it is a mistake where some other value was intended in the assignment.
Example (bad)
1
2
3
4
5
6
7
8
9
10
11
12 | declare
co_parallel_degree constant types_up.name%type := 'parallel_degree';
l_function_result pls_integer;
l_parallel_degree pls_integer;
begin
l_function_result := maintenance.get_config(co_parallel_degree);
if l_function_result is not null then
l_parallel_degree := l_parallel_degree;
do_something(l_parallel_degree);
end if;
end;
/
|
Example (good)
1
2
3
4
5
6
7
8
9
10
11
12 | declare
co_parallel_degree constant types_up.name%type := 'parallel_degree';
l_function_result pls_integer;
l_parallel_degree pls_integer;
begin
l_function_result := maintenance.get_config(co_parallel_degree);
if l_function_result is not null then
l_parallel_degree := l_function_result;
do_something(l_parallel_degree);
end if;
end;
/
|