In SQL Server we can type IsNull()
to determine if a field is null. Is there an equivalent function in PL/SQL?
This question is related to
sql-server
oracle
tsql
plsql
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.
Also use NVL2
as below if you want to return other value from the field_to_check
:
NVL2( field_to_check, value_if_NOT_null, value_if_null )
Usage: ORACLE/PLSQL: NVL2 FUNCTION
Instead of ISNULL()
, use NVL()
.
T-SQL:
SELECT ISNULL(SomeNullableField, 'If null, this value') FROM SomeTable
PL/SQL:
SELECT NVL(SomeNullableField, 'If null, this value') FROM SomeTable
Source: Stackoverflow.com