SQL/MX 3.2 Reference Manual (H06.25+, J06.14+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Release 3.2 Reference Manual691117-001
9-125
NVL2 Function
NVL2 Function
The NVL2 function returns expr2 if expr1 is NOT NULL and returns expr3 if expr1
is NULL.
expr1, expr2, expr3... are SQL value expressions.
The NVL2 function is logically equivalent to the following IF-ELSE expression:
if (expr1 is NOT NULL)
return expr2
else
return expr3
Considerations
The considerations of NVL2 are same as Considerations in NVL.
Examples of NVL2
This function returns colB if colA is NOT NULL else returns integer ‘0’(third
argument of NVL2).
create table tab1(colA varchar(10), colB int);
--- SQL operation complete.
insert into tab1 values('one', 1);
--- 1 row(s) inserted.
-- Default values for colA is NULL
insert into tab1(colB) values(2);
--- 1 row(s) inserted.
NVL2 (expr1, expr2, expr3)