Use nvl in a function : NVL « Char Functions « Oracle PL / SQL






Use nvl in a function

  
SQL>
SQL> create or replace function total_compensation(
  2    p_salary number,
  3    p_commission number ) return number
  4  deterministic as
  5  begin
  6    return nvl(p_salary,0) + nvl(p_commission,0);
  7  end total_compensation;
  8  /

Function created.

SQL>
SQL> select total_compensation(1,2) from dual;

TOTAL_COMPENSATION(1,2)
-----------------------
                      3

SQL>

   
  








Related examples in the same category

1.NVL: Returns a substitute (some other value) if a value is null
2.NVL: Supply an NVL default that is of a different datatype
3.NVL: Provide default value for NULL
4.Use NVL() to convert number columns and date columns
5.NVL() deals with date value
6.Combine nvl and to_char
7.select nvl( '', 'Yes '''' is null' ) "Evaluate"
8. nvl( e2.ename, 'NO BOSS! PARTY TIME!' )
9.Use TRUNC function in NVL function
10.This will fail, because the datatypes of the two arguments are different
11.Accommodate the datatype difference by placing a TO_CHAR function around the LAST_STOCK_DATE
12.Use NVL to check nullment in PL/SQL
13.Use Nvl function in math calculation for null value