Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Using NULLs in Comparisons


DECLARE

x NUMBER := 5;

y NUMBER := NULL;

BEGIN

IF x != y THEN -- yields NULL, not TRUE



dbms_output.Put_line('x != y'); -- not executed

ELSIF x = y THEN -- also yields NULL



dbms_output.Put_line('x = y');

ELSE

dbms_output.Put_line('Can''t tell if x and y are equal or not.');

END IF;

END;

/




In the following example, you might expect the sequence of statements to execute
because a and b seem equal. But, again, that is unknown, so the IF condition yields
NULL and the sequence of statements is bypassed.


DECLARE

a NUMBER := NULL;

b NUMBER := NULL;

BEGIN

IF a = b THEN -- yields NULL, not TRUE



dbms_output.Put_line('a = b'); -- not executed

ELSIF a != b THEN -- yields NULL, not TRUE



dbms_output.Put_line('a != b'); -- not executed

ELSE

dbms_output.Put_line('Can''t tell if two NULLs are equal');

END IF;

END;

/



Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-