Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

How does the following NOT condition work?

ggSep 23 2019 — edited Sep 23 2019

Hi all,

   Kindly consider the following block of code.

set SERVEROUTPUT ON size unlimited

declare

v1 number:=1;

v2 number:=2;

begin

if not (v1=2 and v2=2) then

dbms_output.put_line('condition met');

else

dbms_output.put_line('condition not met');

end if;

end;

/

After executing it i get the output as "condition met".

Can somebody pls explain why do i get the above output and how does NOT work as both the condition in the first IF are not satisfied

V1=1

V2=2

and the condition i have given is "if not (v1=2 and v2=2)" as V2 being 2 makes the first if condition not being met and should print the output in the else condition.

Thanks

Gautam

This post has been answered by Paulzip on Sep 23 2019
Jump to Answer
Comments
Post Details
Added on Sep 23 2019
9 comments
245 views