Skip to main content

Do not compare values against the NULL literal or an empty string

ZPA rule for PL/SQL and Oracle SQL · ComparisonWithNull

To test for nulls, use only the comparison conditions IS NULL and IS NOT NULL. Any other comparison with nulls will result in NULL.

Keep in mind that an empty string is equivalent to a NULL literal.

Noncompliant Code Example​

if var = null then
-- code
end if;

Or:

if other_var = '' then
-- code
end if;

Compliant Solution​

if var is null then
-- code
end if;
if other_var is null then
-- code
end if;