IF

The IF statement has the following syntax:


IF condition1 THEN
   statements1
ELSIF condition2 THEN
   statements2
ELSE
   statements3
END IF;

Example:


SET SERVEROUTPUT ON

SQL> DECLARE
  2   v_width INTEGER := 3;
  3   v_height INTEGER := 2;
  4   v_area INTEGER;
  5  BEGIN
  6   v_area := v_width *  v_height;
  7
  8   IF v_area > 0 THEN
  9     DBMS_OUTPUT.PUT_LINE('area is greater than 0 ');
 10   END IF;
 11  END;
 12  /
area is greater than 0

PL/SQL procedure successfully completed.

SQL>
Home »
Oracle »
PL/SQL » 

Related: