Skip to main content

Do not pass a NULL literal or an empty string to NVL

ZPA rule for PL/SQL and Oracle SQL · NvlWithNullParameter

NVL(a, b) returns b when a is null, and a otherwise. With NULL as the second argument it returns a in every case; with NULL as the first it always returns b. Oracle treats '' as null, so '' does the same. The call does nothing, and usually a default value was meant.

This rule reports a call to NVL with NULL or '' as one of its two arguments.

Examples​

Noncompliant Code Example
l_label := nvl(r_crate.label, ''); -- Noncompliant
Compliant Solution
l_label := nvl(r_crate.label, 'unlabeled');