Skip to content

G-2145: Never self-assign a variable.

Minor

Maintainability

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
declare
   l_function_result pls_integer;
   l_parallel_degree pls_integer;
begin
   l_function_result := maintenance.get_config('parallel_degree');
   l_parallel_degree := l_parallel_degree;
end;
/

Example (good)

1
2
3
4
5
6
7
8
declare
   l_function_result pls_integer;
   l_parallel_degree pls_integer;
begin
   l_function_result := maintenance.get_config('parallel_degree');
   l_parallel_degree := l_function_result;
end;
/