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:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}