nullManagement
isnull
Returns true
if X
is a marked null, false
otherwise.
isnull(X)
Where:
-
X
is the value to be checked if it is a marked null.
Example
@library("null:", "nullManagement").
p(1).
p1(A,B) :- p(A).
v1(X):- p1(A,B), X = null:isnull(B).
@output("v1").
Expected results
v1(true)
v1(false)
ifnull
Returns A
if X
is null, B
otherwise.
ifnull(X, A, B)
Where:
-
X
is the value to be checked if it is null. -
A
is the value to return ifX
is null. -
B
is the value to return ifX
is not null.
Example
@library("null:", "nullManagement").
v3(Residence,Gender,Education,Labor,Weight,RowId,X) :-
v1(Residence,Gender,Education,Labor,Weight,RowId),
X=null:ifnull(Labor,Residence,Education).
@output("v3").
Expected results
v3("Res1", "Male", "Edu1", null, 70, 1, "Res1")
v3("Res2", "Female", "Edu2", "Labor2", 65, 2, "Labor2")
coalesce
Returns X
if X
is not null OR if both X
and Y
are null; returns Y
otherwise.
coalesce(X, Y)
Where:
-
X
is the first value to check. -
Y
is the second value to check.
Example
@library("null:", "nullManagement").
p(1).
p1(A,B) :- p(A).
v1(X):- p1(A,B), X = null:coalesce(B, A).
@output("v1").
Expected results
v1(1)
v1(A)