SQL NULLIF scalar function in DB2 for i SQL

SQL NULLIF scalar function in DB2 for i SQL
SQL NULLIF scalar function in DB2 for i SQL, nullif sql function in ibmi db2
SQL NULLIF scalar function in DB2 for i SQL

NULLIF

The NULLIF function returns the null value if the two parameters are equal, otherwise it returns the value of the first parameter.

Syntax of NULLIF

NULLIF(expression1, expression2)

The result of NULLIF(exp1, exp2) is same as using CASE statement "CASE WHEN exp1=exp2 THEN NULL ELSE exp1 END"

Example using NULLIF

SELECT NULLIF(1,1), NULLIF(1,2) FROM sysibm.sysdummy1 

Output:

NULLIF ( 1 , 1 )  NULLIF ( 1 , 2 )
               -                1 

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain