NVL2

来源:互联网 发布:石大在线网络教育 编辑:程序博客网 时间:2024/05/01 17:31

Purpose

NVL2 lets you determine the value returned by a query based on whether a specified expression is null or not null.

If expr1 is not null, then NVL2 returns expr2. If expr1 is null, then NVL2 returns expr3.

如果expr1非空,则返回 expr2,如果expr1是空值,则返回expr3

The argument expr1 can have any data type. The arguments expr2 and expr3 can have any data types except LONG.

expr1 可以是任意数据类型, expr2 and expr3 可以是任意数据类型,但不能是LONG类型,且数据类型要一致,或者隐式转换为一致,或者显示转换为一致。

If the data types of expr2 and expr3 are different, then Oracle Database implicitly converts one to the other.

如果expr2 and expr3 数据类型不同,则隐式转为相同

 If they cannot be converted implicitly, then the database returns an error.

如果不能隐式转换,则报错。

If expr2 is character or numeric data, then the implicit conversion is implemented as follows:

  • If expr2 is character data, then Oracle Database converts expr3 to the data type of expr2 before returning a value unless expr3 is a null constant.
  • In that case, a data type conversion is not necessary, and the database returns VARCHAR2 in the character set of expr2.
  • 如果expr2 是字符类型,则将expr3 转换为expr2相同的数据类型。
  • If expr2 is numeric data, then Oracle Database determines which argument has the highest numeric precedence, implicitly converts the other argument to that data type, and returns that data type.
0 0
原创粉丝点击