Thursday 11 October 2012

NULLIF Function in Oracle

NULLIF:
  • The NULLIF function can be thought as null-if-equals function. 
  • It compares two expressions. If they are equal server returns a null and If they not equal [or] if the second expression is null, the first expression is returned. 
  • Both the compared expressions shall be source values.
SELECT NULLIF(22,22)FROM DUAL;
NULLIF(22,22)
-------------


SELECT NULLIF(22,23)FROM DUAL;
NULLIF(22,23)
-------------
           22


SELECT NULLIF(22,NULL)FROM DUAL;
NULLIF(22,NULL)
---------------
             22


SELECT NULLIF(NULL,NULL)FROM DUAL;
--IS WRONG

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

ShareThis