Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Comparing a value with NULL

212595Feb 24 2004 — edited Mar 19 2008
Hi,
A funny thing is happening to me. Is it only in oracle 9i or in every version.
I am working on a state project on Data Warehousing and faced a small BUG. Here is the sample code.

DECLARE
v_Var varchar2(10) := 'a';
v_Null varchar2(10) := null;
BEGIN
IF v_Var != v_Null THEN
DBMS_OUTPUT.PUT_LINE('First: Not equal');
ELSE
DBMS_OUTPUT.PUT_LINE('First: Equal');
END IF;

IF v_Var = v_Null THEN
DBMS_OUTPUT.PUT_LINE('Second: Equal');
ELSE
DBMS_OUTPUT.PUT_LINE('Second: Not equal');
END IF;
END;
/


This anonymous block should return Not Equal for both the statements, but unfortunately it returns Equal for the First and Not equal for the Second.

Is this a BUG?
Is this happening only in version 9i (I use version 9.2.0.1.0)?

Any help/suggestion is appreciated.
Thanks! :)
Kamal Vala
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2004
Added on Feb 24 2004
12 comments
1,132 views