Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> String Compare in PL/SQL

String Compare in PL/SQL

From: <hvande_at_sapient.com>
Date: Tue, 06 Oct 1998 13:40:20 GMT
Message-ID: <6vd6k4$ium$1@nnrp1.dejanews.com>


I noticed an interesting issue in some of my PL/SQL code that I have not see before. Here is a snip of the code that describes the problem:

declare
  v_text varchar2(200);
begin
  v_text := '';

  if v_text != 'hello'
  then

     dbms_output.put_line('NOT Equal');   else

     dbms_output.put_line('Equal');
  end if;
end;

When I run this program it gives me the result of 'Equal' which is NOT true. However is I specify a different value for v_text, e.g. v_text := 'foo'. Then the code displays 'NOT Equal'. My best guess is that Oracle translates an empty string to a NULL, which is not the same thing. So the question is: is this a bug or should I be doing something else?

Thanks,

Henri
hvande_at_sapient.com

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Tue Oct 06 1998 - 08:40:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US