Hi,
I would like to use NVL2 function inside PL/SQL (actually I need it inside Cursor For loop, but in this simplified example doesn't work either) block but I get error PLS-00201: identifier 'NVL2' must be declared when I run script. Similar NVL works Ok. If I use NVL2 inside stand alone SQL statement (below) works ok. Why this doesn't work here and what builtin function I can use instead of this one so I can get same functionality if this cannot be used?
Declare
v_Res1 VarChar2(1000) := 'SALESMAN';
v_Res2 VarChar2(1000) := 'SALESMAN';
v_Res3 VarChar2(1000) := 'SALESMAN';
Begin
v_Res1 := NVL(v_Res1, 'Null');
DBMS_OutPut.Put_Line('v_Res1: ' || v_Res1); -- Work Ok
Select NVL2(v_Res2, 'NotNull', 'Null')
Into v_Res2
From Dual;
DBMS_OutPut.Put_Line('v_Res2: ' || v_Res2); -- Work Ok
v_Res3 := NVL2(v_Res3, 'NotNull', 'Null'); -- Why this doesn't work?
DBMS_OutPut.Put_Line('v_Res3: ' || v_Res3);
End;
/
Select NVL2('SALESMAN', 'NotNull', 'Null')
From Dual; -- Work Ok
/
BB