How Can We Help?
Description:
In this tutorial we will explains how to use Oracle NVL() function with basic syntax and many examples for better understanding.
Oracle NVL function replace null value with another meaningful value you specify.
Syntax:
NVL( expr1, expr2)
Name | Description | Data Types |
expr1 | the first expression that you want to substitute. | it could be any data type |
expr2 | the secord expression that you want to replace null value of expr1 with. | it could be any data type |
Notes:
- Oracle NVL return a substitute value .
- If both expr1 and expr2 datatypes are different, then Oracle Database implicitly converts one to the other.
- If they are cannot be converted implicitly, the database returns an error.
- If expr1 is character data, then Oracle Database converts expr2 to the datatype of expr1 before comparing them and returns VARCHAR2 in the character set of expr1.
- If expr1 is numeric, then Oracle determines which argument has the highest numeric precedence, implicitly converts the other argument to that datatype, and returns that datatype.
Examples:
SELECT contact_title, nvl (contact_title, 'N/A') FROM suppliers;
In above example Oracle NVL replace null value of contact_title column with ‘N/A’.
In this tutorial, you have learned how to use Oracle NVL() function to replace null value with another meaningful value you given.
Hopefully, it was clear and concise.