Skip to main content

Unnecessary concatenation with NULL value

ZPA rule for PL/SQL and Oracle SQL · ConcatenationWithNull

Oracle treats NULL and '' as an empty string in a concatenation, so concatenating them adds nothing. The operand is either left over from an edit, or written to convert a value to text implicitly ('' || id), which hides the conversion and its format.

This rule reports NULL or '' written as an operand of ||. Remove it, or write the conversion with TO_CHAR.

Examples​

Noncompliant Code Example
l_text := nvl('' || r_crate.id, 'none'); -- Noncompliant
Compliant Solution
l_text := nvl(to_char(r_crate.id), 'none');