You should specify your Oracle version. I assume you are using 8i, where NVL2 (like some other newer functions) does not work inside PLSQL. The reason is a separate SQL parser that's built into PL/SQL, and this one does not yet support all the features available in SQL. If you want to use NVL2 in 8i PL/SQL you should use dyinamic SQL (DBMS_SQL or 'EXECUTE IMMEDIATE').
In 9i there is only one SQL parser for both SQL and PL/SQL, so NVL2 works also from inside PL/SQL.
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?