SQL Server的IsNull()函数的Oracle等效项是什么?

时间:2022-12-08 15:45:06

In SQL Server we can type IsNull() to determine if a field is null. Is there an equivalent function in PL/SQL?

在SQL Server中,我们可以输入IsNull()来确定字段是否为空。PL/SQL中是否有相同的函数?

4 个解决方案

#1


107  

coalesce is supported in both Oracle and SQL Server and serves essentially the same function as nvl and isnull. (There are some important differences, coalesce can take an arbitrary number of arguments, and returns the first non-null one. The return type for isnull matches the type of the first argument, that is not true for coalesce, at least on SQL Server.)

在Oracle和SQL Server中都支持coalesce,它的功能与nvl和isnull基本相同。(有一些重要的区别,联合可以取任意数量的参数,并返回第一个非空参数。isnull的返回类型与第一个参数的类型相匹配,但这并不适用于coalesce,至少在SQL Server上是如此。

#2


89  

Instead of ISNULL(), use NVL().

使用NVL()代替ISNULL()。

T-SQL:

t - sql:

SELECT ISNULL(SomeNullableField, 'If null, this value') FROM SomeTable

PL/SQL:

PL / SQL:

SELECT NVL(SomeNullableField, 'If null, this value') FROM SomeTable

#3


20  

Also use NVL2 as below if you want to return other value from the field_to_check:

如果您想要从field_to_check返回其他值,也可以使用NVL2如下:

NVL2( field_to_check, value_if_NOT_null, value_if_null )

Usage: ORACLE/PLSQL: NVL2 FUNCTION

用法:ORACLE / PLSQL:NVL2函数

#4


6  

You can use the condition if x is not null then.... It's not a function. There's also the NVL() function, a good example of usage here: NVL function ref.

您可以使用条件如果x不是null,那么....这不是一个函数。还有NVL()函数,这是一个很好的使用例子:NVL函数ref。

#1


107  

coalesce is supported in both Oracle and SQL Server and serves essentially the same function as nvl and isnull. (There are some important differences, coalesce can take an arbitrary number of arguments, and returns the first non-null one. The return type for isnull matches the type of the first argument, that is not true for coalesce, at least on SQL Server.)

在Oracle和SQL Server中都支持coalesce,它的功能与nvl和isnull基本相同。(有一些重要的区别,联合可以取任意数量的参数,并返回第一个非空参数。isnull的返回类型与第一个参数的类型相匹配,但这并不适用于coalesce,至少在SQL Server上是如此。

#2


89  

Instead of ISNULL(), use NVL().

使用NVL()代替ISNULL()。

T-SQL:

t - sql:

SELECT ISNULL(SomeNullableField, 'If null, this value') FROM SomeTable

PL/SQL:

PL / SQL:

SELECT NVL(SomeNullableField, 'If null, this value') FROM SomeTable

#3


20  

Also use NVL2 as below if you want to return other value from the field_to_check:

如果您想要从field_to_check返回其他值,也可以使用NVL2如下:

NVL2( field_to_check, value_if_NOT_null, value_if_null )

Usage: ORACLE/PLSQL: NVL2 FUNCTION

用法:ORACLE / PLSQL:NVL2函数

#4


6  

You can use the condition if x is not null then.... It's not a function. There's also the NVL() function, a good example of usage here: NVL function ref.

您可以使用条件如果x不是null,那么....这不是一个函数。还有NVL()函数,这是一个很好的使用例子:NVL函数ref。