Ticker

6/recent/ticker-posts

NVL() Function in Oracle

In this SQL Tutorial, We will explore the NVL() Function in Oracle.

NVL() Function in Oracle SQL

What is NVL() Function in Oracle?

NVL() is used to replace  NULL string with another string or you can say in the simple words that NVL is a function for handling NULL values in the table.

Syntax of NVL() function in Oracle

NVL(Argument1,Argument2)

Example of NVL() function in Oracle

select NVL(SAL,0) from EMP

Let's compare, When we are not using NVL() function in the SQL statement and when we are using the NVL() function in SQL statement. The below image will show  the difference to you.

nvl() function in oracle example
Image 1

nvl function in oracle sql with example
Image 2

Important Note:-

1)In the NVL function we have two arguments and both are required.if you missed any arguments in the NVL() function the oracle will return a syntax error(ORA-00936: missing expression).

Select NVL(,0) from dual---ORA-00936: missing expression--

2)In the NVL function, we have same datatype values otherwise oracle will return an error(ORA-01722: invalid number).

Select NVL(0,'A') from dual

3) If you don't want to above error the convert values in the same datatype.

Select NVL(to_char(0),'A') from dual

That's all for today, I think(NVL() Function in Oracle) post will be helpful for you. If you like the post then share your view in the comment box.

Post a Comment

0 Comments