Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL NULLIF Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: NULLIF

Definition:
The Oracle NULLIF function is a null handling function which accepts two numeric arguments. If both of the arguments are equal it returns NULL; otherwise it returns the first argument. It is most commonly used for handling the ZERO_DIVIDE exception.

Example Syntax:

NULLIF(arg1, arg2)


where arg1 and arg2 are of the NUMBER datatype.

Example Usage:

The SQL example below raises a ZERO_DIVIDE exception as it foolishly tries to divide a number by zero.

SQL> SELECT 12/0 FROM DUAL;
select 12/0 from dual
*
ERROR at line 1:
ORA-01476: divisor is equal to zero


The SQL example below handles the exception raised above by using the NULLIF function in the Divisor.

SQL> SELECT 12/NULLIF(0,0) FROM DUAL;

12/NULLIF(0,0)
--------------



Related Links:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 146 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?