Skip to main content

Identical conditions should not be duplicated

ZPA rule for PL/SQL and Oracle SQL · SameCondition

A condition repeated in the same chain of AND or OR adds nothing: a AND a is a. It is almost always a copy and paste where the second condition should test another column or value, so the filter or the decision is not the one intended.

This rule reports a condition of an AND or OR chain that is the same as an earlier one of that chain, parentheses aside.

Examples​

Noncompliant Code Example
select count(*)
into l_full
from rack
where capacity <= used
and capacity <= used; -- Noncompliant
Compliant Solution
select count(*)
into l_full
from rack
where capacity <= used
and active = 'Y';