Do not use a sequence NEXTVAL in a conditional CASE
or built-in DECODE result when the value appears to be consumed
only by the selected branch.
Oracle sequences are special expressions in SQL. A conditional result can be
correct while evaluating NEXTVAL still advances the sequence. Keep
the sequence operation outside the conditional result when that side effect
must be conditional.
select case when status = 'NEW' then order_seq.nextval else 0 end from orders;
This rule reports only sequence references that ZPA can positively identify
from project declarations. References to sequences outside the analyzed project
may remain undetected. For DECODE, only an unqualified unquoted
call (case-insensitive) or a quoted identifier spelled exactly
"DECODE" call is treated as Oracle's built-in function. The
main expression and search expressions are not conditional results.