NULL : It is a value which is
- Unavailable
- Unassigned
- Unknown
- Inapplicable
If a row lacks the data for a particular column, than that value is said to be NULL or to contain NULL.
SQL>SELECT Ename, Job, Sal, Comm FROM Emp;If any column value is an arithmetic expression in NULL, the overall result is also NULL.
The above situation is termed as NULL propagation and has to be handled very carefully.
SQL>SELECT Ename, Job, Sal, Comm,12 * SAL + Comm FROM Emp;NVL Function : The NVL function is used to convert a NULL value to an actual value.
Syntax :
NVL(expr1,expr2)expr1 : is the source value or expression that may contain NULL.
expr2 : is the target valued for converting NULL.
NVL function can be used to convert any data type, the return value is always the same as the data type of expr1.
The data types of the source and destination must match.
NVL(Comm,0)
NVL(Hiredate,'06-sep-09')
NVL(Job,'Not assigned')
SQL>SELECT Ename, Job, Sal, Comm, Sal+NVL(Comm,0) FROM Emp;
SQL>SELECT Ename, Job, Sal, Comm, (Sal+12) + NVL(Comm,0) FROM Emp;



0 comments
Post a Comment
Do comment to make this blog better