DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

PL/SQL Comparaison Between 2 Varchar When One Is NULL

09.10.2010
| 3275 views |
  • submit to reddit
        This is a PL/SQL piece of code on Oracle 9i.
The <> operator does not work as desired with strings.

declare
  text1 varchar2(100);
  text2 varchar2(100);
begin
  text1 := 'toto';
  text2 := NULL;
  
  if text1 <> text2 then
    dbms_output.put_line('true');
  else
    dbms_output.put_line('false');
  end if;
end;

Result:
false