Nullif

From Oracle FAQ
(Redirected from NULLIF)
⧼orafaq-jumptonavigation⧽⧼orafaq-jumptosearch⧽

Nullif is an SQL function that returns a NULL value if both parameters are equal in value. If not, the first value will be returned.

This function is mostly provided for compatibility with other database systems (like SQL Server) and not frequently used in the Oracle world.

Examples

This query will return NULL:

SELECT NULLIF(ename, ename) FROM emp;

This query will return 1:

SELECT NULLIF(1, 2) FROM dual;

The following query will return NULL if the bind variable 'b' is zero-valued, otherwise it will return the inverse of b:

SELECT 1 / NULLIF(:b, 0) FROM emp;

Also see

Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #