Difference between revisions of "NVL()"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision) |
|||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Function to specify an alternative value for a null expression | Function to specify an alternative value for a null expression | ||
− | |||
==Syntax== | ==Syntax== | ||
NVL(<expr1>,<expr2>) | NVL(<expr1>,<expr2>) | ||
− | |||
==See Also== | ==See Also== | ||
− | [[ETOS()]], [[ISNULL()]], [[SET NULL]], [[SET NULLDISPLAY]] | + | [[ETOS()]], [[IFNULL()]], [[ISNULL()]], [[SET NULL]], [[SET NULLDISPLAY]] |
− | + | ||
==Description== | ==Description== | ||
The NVL() function evaluates the expression in <expr1>, and if the expression does not evaluate to NULL, the evaluated result is returned. If the expression in <expr1> does evaluate to NULL, the expression in <expr2> is evaluated. If <expr2> does not evaluate to NULL, the evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the NVL() function returns NULL. | The NVL() function evaluates the expression in <expr1>, and if the expression does not evaluate to NULL, the evaluated result is returned. If the expression in <expr1> does evaluate to NULL, the expression in <expr2> is evaluated. If <expr2> does not evaluate to NULL, the evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the NVL() function returns NULL. | ||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | |||
set null on | set null on | ||
CREATE TABLE nullon (firstname c(20), lastname c(20)) | CREATE TABLE nullon (firstname c(20), lastname c(20)) | ||
Line 24: | Line 19: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Category:Expressions and Type Conversion]] | [[Category:Expressions and Type Conversion]] | ||
[[Category:Expressions and Type Conversion Functions]] | [[Category:Expressions and Type Conversion Functions]] |
Revision as of 10:47, 3 October 2012
Contents
Purpose
Function to specify an alternative value for a null expression
Syntax
NVL(<expr1>,<expr2>)
See Also
ETOS(), IFNULL(), ISNULL(), SET NULL, SET NULLDISPLAY
Description
The NVL() function evaluates the expression in <expr1>, and if the expression does not evaluate to NULL, the evaluated result is returned. If the expression in <expr1> does evaluate to NULL, the expression in <expr2> is evaluated. If <expr2> does not evaluate to NULL, the evaluated result is returned. If both <expr1> and <expr2> evaluate to NULL, the NVL() function returns NULL.
Example
set null on CREATE TABLE nullon (firstname c(20), lastname c(20)) INSERT INTO nullon (lastname) VALUES ("Smith") SELECT lastname, nvl(firstname,"Unknown") from nullon