What is Unknown in logical operator [message #659414] |
Mon, 16 January 2017 04:30 |
|
asliyanage
Messages: 60 Registered: January 2017
|
Member |
|
|
I found that logical operator(AND,OR,NOT) can have state unknown(True,False,Unknown). I understand the true and false. But what is the Unknown state. When is the these logical operator have unknown state?
|
|
|
|
Re: What is Unknown in logical operator [message #659419 is a reply to message #659414] |
Mon, 16 January 2017 04:47 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
In oracle, you get unknown when one or more of the values you're comparing is null:
declare
l varchar2(1);
m varchar2(1) := 'A';
bool boolean;
begin
bool := (l=m);
IF bool = TRUE THEN
dbms_output.put_line('comparsion is true');
ELSIF bool = FALSE THEN
dbms_output.put_line('comparsion is false');
ELSE
dbms_output.put_line('comparsion is unknown');
END IF;
--With AND
bool := (l=m) AND 1=1;
IF bool = TRUE THEN
dbms_output.put_line('AND comparsion is true');
ELSIF bool = FALSE THEN
dbms_output.put_line('AND comparsion is false');
ELSE
dbms_output.put_line('AND comparsion is unknown');
END IF;
IF NOT bool THEN
dbms_output.put_line('NOT bool');
ELSE
dbms_output.put_line('NOT NOT bool, because it''s not false');
END IF;
-- WITH OR
bool := (l=m) OR 1=1;
IF bool = TRUE THEN
dbms_output.put_line('OR comparsion is true');
ELSIF bool = FALSE THEN
dbms_output.put_line('OR comparsion is false');
ELSE
dbms_output.put_line('OR comparsion is unknown');
END IF;
end;
comparsion is unknown
AND comparsion is unknown
NOT NOT bool, because it's not false
OR comparsion is true
PL/SQL procedure successfully completed.
|
|
|
|
Re: What is Unknown in logical operator [message #660278 is a reply to message #660274] |
Tue, 14 February 2017 01:53 |
|
Michel Cadot
Messages: 68643 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
This is a little bit short when this "thank" is asked to you and given by you just to get another help.
Feedback means you tell what you learn from this so we know if you clearly understood and future comers will be helped just reading your final post.
|
|
|