Introduction

In the following code, the two IF statements appear to be equivalent.

If either x or y is NULL, then the first IF statement assigns the value of y to high and the second IF statement assigns the value of x to high.

Demo

SQL>
SQL> DECLARE-- from  w  ww.  ja v a 2s.co  m
  2    x    INTEGER := 2;
  3    Y    INTEGER := 5;
  4    high INTEGER;
  5  BEGIN
  6    DBMS_OUTPUT.PUT_LINE('high:'||TO_CHAR(high));
  7    IF (x > y)       
  8    THEN high := x; 
  9    ELSE high := y; 
 10    END IF;
 11
 12
 13    DBMS_OUTPUT.PUT_LINE('high:'||TO_CHAR(high));
 14
 15    IF NOT (x > y)   
 16    THEN high := y;  
 17    ELSE high := x;  
 18    END IF;
 19    DBMS_OUTPUT.PUT_LINE('high:'||TO_CHAR(high));
 20  END;
 21  /
high:
high:5
high:5

PL/SQL procedure successfully completed.

SQL>

Related Topic