• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / function / NULLIF Function in Oracle SQL – PLSQL

NULLIF Function in Oracle SQL – PLSQL

November 28, 2012 by techhoneyadmin

Oracle SQL / PLSQL used the NULLIF function to compare 2 expressions.

If the expressions are equal then the SQL NULLIF function returns NULL, else SQL NULLIF function will return the first expression.

Oracle SQL / PLSQL Syntax for the NULLIF function is:

SELECT NULLIF (expression_1, expression_2)
FROM table_name;

Here, expression_1 and expression_2 are the expressions to be compared.

Example: Using Oracle SQL /PLSQL NULLIF Function in SQL SELECT Statement

 SELECT NULLIF(1,1)
FROM dual;

Will return NULL

 SELECT NULLIF(1,2)
FROM dual;

Will return 2

 SELECT NULLIF('Tech Honey','Tech Honey')
FROM dual;

Will return NULL

 SELECT NULLIF('Tech','Honey')
FROM dual;

Will return ‘Tech’

 SELECT NULLIF(NULL,'Honey')
FROM dual;

Will return an ORA-00932 error because expression_1 cannot be literal NULL.

The example above shows use of Oracle SQL / PLSQL NULLIF Function.


Filed Under: function Tagged With: Compare two expressions usin oracle sql plsql NULLIF function, How to use NULLIF function in oracle sql plsql with example, NULLIFPLSQL

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in