Over a million developers have joined DZone.

PL/SQL Comparaison Between 2 Varchar When One Is NULL

·
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
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}