Creating a Boolean/Logical datatype with InterBase

By: Borland Staff

Abstract: Booleans can be simulated by created a CHAR(1) with a check contraint that allows Y or N to be entered

Problem:
InterBase does not have a native Boolean/Logical datatype.  
How can I create one myself?

Solution:
Option 1:
---------------

Create a field of type CHAR and use CHECK CONSTRAINTS to limit
the values that are allowed to be entered into it.

Example:
	
      CHAR(1) CHECK (VALUE IN ("Y", "N")) NOT NULL;

Option 2:
----------------

Similar to above but use a domain to create a global data type for
the database so that you may reuse the data type more easily.

Example:

      CREATE DOMAIN YN AS CHAR(1) CHECK (VALUE IN ("Y","N")) NOT NULL;

Server Response from: ETNASC04