BOOLEAN type

2023-10-31 11:17:11  Updated

The BOOLEAN type stores the results of logical operations.

Applicability

This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.

The valid value of the BOOLEAN type is TRUE, FALSE, or NULL. NULL indicates that the result is unknown.

The syntax for value assignment is as follows:

variable_name BOOLEAN

BOOLEAN is not a valid SQL type, so the following limitations apply when you use it:

  • You cannot assign a BOOLEAN value to a table column.

  • You cannot assign a data in a table to a BOOLEAN variable.

  • You cannot use a BOOLEAN variable in any SQL function.

  • You cannot use a BOOLEAN expression in an SQL statement unless you pass it in through a PL function.

Here is an example:

obclient> CREATE OR REPLACE PROCEDURE output_bool (b BOOLEAN)
AUTHID DEFINER IS
BEGIN
  DBMS_OUTPUT.PUT_LINE (
    CASE
      WHEN b IS NULL THEN 'NA'
      WHEN b THEN 'Y'
      WHEN NOT b THEN 'N'
    END
  );
END;
/
obclient> BEGIN
  output_bool(TRUE);
  output_bool(FALSE);
  output_bool(NULL);
END;
 /
Query OK, 0 rows affected

Y
N
N/A                       

Contact Us