Define and use boolean value : Boolean « Data Type « Oracle PL / SQL






Define and use boolean value

  

SQL>
SQL> --  Effects of nulls on boolean expressions.
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
  2     a     INTEGER;
  3     n     INTEGER;     -- be our null value.
  4     b     BOOLEAN;
  5  BEGIN
  6     -- Assign a value to the variable A, but leave N null.
  7     a := 2;
  8     b := (a <> n);
  9
 10     IF b THEN
 11       DBMS_OUTPUT.PUT_LINE('a <> n is TRUE');
 12     ELSIF NOT b THEN
 13       DBMS_OUTPUT.PUT_LINE('a <> n is FALSE');
 14     ELSE
 15       DBMS_OUTPUT.PUT_LINE('a <> n is NULL');
 16     END IF;
 17  END;
 18  /
a <> n is NULL

PL/SQL procedure successfully completed.

SQL>
           
         
    
  








Related examples in the same category

1.PL/SQL BOOLEAN datatypes accept only TRUE, FALSE, NULL
2.Boolean data type with If statement
3.Use the NVL() against a non-initialized BOOLEAN variable:
4.Boolean literals
5.Boolean expressions in where clause
6.Assign a value to a variable of type boolean. Don't use quotes around the value like this