NULLIF function
NULLIF(e1, e2)
returns NULL
if e1
and e2
are the same. Otherwise, it returns e1.
e1
and e2
must have the same datatype.
SQL> SELECT NULLIF(1,null) FROM dual;
NULLIF(1,NULL)
--------------
1
SQL>
SQL> SELECT NULLIF('1','1') FROM dual;
N
-
SQL>
SQL> SELECT NULLIF(1,1) FROM dual;
NULLIF(1,1)
-----------
SQL>
SQL>
SQL> SELECT NULLIF(1,'1') FROM dual;
SELECT NULLIF(1,'1') FROM dual
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got CHAR
SQL>
SQL>
SQL> SELECT NULLIF(null,null) FROM dual;
SELECT NULLIF(null,null) FROM dual
*
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected - got CHAR
SQL>