Developer

Learn Oracle: Datatypes for SQL and PL/SQL, Boolean and Large Objects (LOB)

Use the article index for more articles on this subject.

BOOLEAN


A

BOOLEAN datatype is a native PL/SQL type that lets you signify a TRUE

or FALSE condition. A BOOLEAN is NULL until explicitly assigned a

value. A BOOLEAN is assigned like other variables:

DECLARE
  v_bool BOOLEAN; 
  v_bool2 BOOLEAN := TRUE; 
  v_bool3 BOOLEAN := FALSE;
BEGIN 
  v_bool := TRUE;
END;

A

BOOLEAN can also be assigned by a boolean expression. Instead of type

two statements, you can combine it into a single statement:

DECLARE 
  v_bool BOOLEAN; 
  v_num NUMBER := 1;
BEGIN  
  v_bool := (v_num = 1);   

  — Is equivaqlent to 
  IF v_num = 1 
  THEN 
    v_bool := TRUE; 
  ELSE 
    v_bool := FALSE; 
  END IF;
END;

You use a BOOLEAN just like you would use a boolean expression.

Read the rest of this post.

Editor's Picks