From Oracle FAQ
Jump to: navigation, search

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.

[edit] Examples

This query will return NULL:

SELECT NULLIF(ename, ename) FROM emp;

This query will return 1:


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;

[edit] 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 #