ORACLE 数据库函数-NULLIF

NULLIF:ORACLE  null相关的函数


语法NULLIF( expr1 , expr2)


Purpose

NULLIF compares  expr1 and  expr2. If they are equal, then the function returns null. If they are not equal, then the function returns  expr1. You cannot specify the literal  NULL for  expr1.

If both arguments are numeric data types, then Oracle Database determines the argument with the higher numeric precedence, implicitly converts the other argument to that data type, and returns that data type. If the arguments are not numeric, then they must be of the same data type, or Oracle returns an error.

The  NULLIF function is logically equivalent to the following  CASE expression:

CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END


用途


NULLIF比较expr1和expr2。

如果两个参数相等,则返回NULL,如果两个表达式不相等,NULLIF 返回第一个 expr1 的值。

如果两个参数都是数值数据类型,则Oracle数据库将确定具有较高数值优先级的参数,隐式地将另一个参数转换为该数据类型,并返回该数据类型。如果参数不是数字,则它们必须是相同的数据类型,否则Oracle将返回错误。

等价语句:CASE WHEN expr1= expr2  THEN null ELSE  expr1 END

请使用浏览器的分享功能分享到微信等