NVL | Oracle/PLSQL: NVL Function

      No Comments on NVL | Oracle/PLSQL: NVL Function
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

NVL function is used to substitute a value when a null value is encountered.This is useful in PL/SQL programming where we can supply default values when there is a chance of getting null at run time or to provide useful logging messages.

Example is given below.

SQL> set serveroutput on;
SQL> -- Created on 12/1/2008 by PLSQLTech Tips
SQL> declare
-- Local variables here
myStr varchar2(100);
begin
--Initialize the String
myStr := 'This is my string';
dbms_output.put_line(nvl(myStr,'This is to replace if string is null'));
--Now set the String to null;
myStr := null;
dbms_output.put_line(nvl(myStr,'This is to replace if string is null'));
end;
/

This is my string
This is to replace if string is null
PL/SQL procedure successfully completed.
SQL>

Technorati Tags:
, , ,

0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Buffer 0 Email -- Filament.io 0 Flares ×

Leave a Reply

Your email address will not be published. Required fields are marked *

Paged comment generated by AJAX Comment Page