Difference between revisions of "ISNULL()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
(Example)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Function to test if an expression evaluates to NULL
+
Function to test if an expression evaluates to NULL and optionally specify an alternative value for a null expression
 
+
  
 
==Syntax==
 
==Syntax==
ISNULL(<expr>)
+
ISNULL(<expr1> [, <expr2>])
 
+
  
 
==See Also==
 
==See Also==
[[EMPTY()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[NVL()]], [[SET NULL]], [[SET NULLDISPLAY]]
+
[[COALESCE()]], [[EMPTY()]], [[IFNULL()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[NVL()]], [[SET NULL]], [[SET NULLDISPLAY]]
 
+
  
 
==Description==
 
==Description==
The ISNULL() function will return True (.T.) if the specified expression, <expr> is NULL otherwise False (.F.).
+
The ISNULL() function evaluates the expression in <expr1>, and returns true (.T.) if the expression evaluates to NULL, otherwise false (.F.).  If the optional <expr2> is specified, ISNULL() returns the first non-null value: if <expr1> does not evaluate to NULL, the evaluated result is returned, otherwise <expr2> is evaluated and if it does not evaluate to NULL, its evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the ISNULL() function returns NULL.
  
 +
From Lianja v4.2, ISNULL() can also be used to check for the existence of a dynamic array / object member.  If the member does not exist, ISNULL() will return .T.; if it does exist, ISNULL() will return .F.
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
select account_no, isnull(last_name) from customer;
+
set null on
 +
CREATE TABLE nullon (firstname c(20), lastname c(20))
 +
INSERT INTO nullon (lastname) VALUES ("Smith")
 +
SELECT lastname, isnull(firstname,"Unknown") from nullon
 +
SELECT lastname, isnull(firstname) from nullon
 +
 
 +
// Check for existence of dynamic array / object member
 +
declare da[]
 +
da.name = "Lianja Inc"
 +
? isnull(da["name"])      // .F.
 +
? isnull(da["address"])  // .T.
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Expressions and Type Conversion]]
+
[[Category:Formatting Functions]]
[[Category:Expressions and Type Conversion Functions]]
+

Latest revision as of 07:17, 13 June 2018

Purpose

Function to test if an expression evaluates to NULL and optionally specify an alternative value for a null expression

Syntax

ISNULL(<expr1> [, <expr2>])

See Also

COALESCE(), EMPTY(), IFNULL(), ISALPHA(), ISBLANK(), ISDIGIT(), NVL(), SET NULL, SET NULLDISPLAY

Description

The ISNULL() function evaluates the expression in <expr1>, and returns true (.T.) if the expression evaluates to NULL, otherwise false (.F.). If the optional <expr2> is specified, ISNULL() returns the first non-null value: if <expr1> does not evaluate to NULL, the evaluated result is returned, otherwise <expr2> is evaluated and if it does not evaluate to NULL, its evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the ISNULL() function returns NULL.

From Lianja v4.2, ISNULL() can also be used to check for the existence of a dynamic array / object member. If the member does not exist, ISNULL() will return .T.; if it does exist, ISNULL() will return .F.

Example

set null on
CREATE TABLE nullon (firstname c(20), lastname c(20))
INSERT INTO nullon (lastname) VALUES ("Smith")
SELECT lastname, isnull(firstname,"Unknown") from nullon
SELECT lastname, isnull(firstname) from nullon
 
// Check for existence of dynamic array / object member
declare da[]
da.name = "Lianja Inc"
? isnull(da["name"])      // .F.
? isnull(da["address"])   // .T.