Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are NVL functions called "NVL"?

Tags:

java

database

nvl

Sometimes I see an nvl() function in code. In the case of Java, it looks like this:

public static String nvl(String value, String alternateValue) {
    if (value == null)
        return alternateValue;

    return value;
}

I understand what this function does, but I don't understand why it's called nvl. Why not checkNotNull or returnNotNull? What does NVL stand for?

I guess Null Value L...?

like image 787
c0rp Avatar asked Mar 09 '15 05:03

c0rp


People also ask

What is meant by NVL?

Unlike a lot of programming/database terms, NVL is not an acronym for anything. It's just NVL, though it can help to think of it as Null VaLue. NVL is a substitution function; that is, it is used to display one value if another value is NULL. And not just zero, but NULL, empty, void.

What does NVL stand for in SQL?

The abbreviation NVL stands for "Null Value".

What does NVL mean in Oracle?

NVL lets you replace null (returned as a blank) with a string in the results of a query. If expr1 is null, then NVL returns expr2 . If expr1 is not null, then NVL returns expr1 .

Why is NVL used?

The NVL function allows you to replace null values with a default value. If the value in the first parameter is null, the function returns the value in the second parameter. If the first parameter is any value other than null, it is returned unchanged.


1 Answers

As others have pointed out in comments, it probably stands for "null value" or "null value logic". It might just as well be called "dflt" (or similar abbreviation) for "default".

And, in Java, it should really be using generics so that it can work on any type ;)

like image 105
Atsby Avatar answered Oct 22 '22 00:10

Atsby