Subject | Re: [ib-support] BOOLEANS |
---|---|
Author | Helen Borrie |
Post date | 2003-03-02T22:03:57Z |
At 07:15 AM 3/03/2003 +1000, you wrote:
you prefer: smallint or char are best because of size. Unless you have a
special reason to want to enforce a value, your check constraint should
include allowing NULL.
otoh, if you DO want to enforce a value, you will need to make the domain
NOT NULL and provide a default, or Before Insert and Before Update triggers
to write a default.
CREATE DOMAIN D_Bool AS SMALLINT DEFAULT 0 NOT NULL
CHECK (VALUE IN 0, 1) ;
Note that DEFAULT fires only on an insert and only if the column is not
included in the insert query specification.
CREATE DOMAIN D_Bool AS SMALLINT
CHECK (VALUE IS NULL OR VALUE IN (0, 1));
heLen
>I am looking but I see no boolean datatype.Correct, it is coming in v.1.5 or v.2 though
>Am I to assume that the standard way to create a boolean isYes - typos apart! :) You can set up a boolean domain as any two values
>
>CREATE DOMAIN D_Bool AS INTEGER
> CHECK ((VALUE = 0) OR (VALUE - 1));
you prefer: smallint or char are best because of size. Unless you have a
special reason to want to enforce a value, your check constraint should
include allowing NULL.
otoh, if you DO want to enforce a value, you will need to make the domain
NOT NULL and provide a default, or Before Insert and Before Update triggers
to write a default.
CREATE DOMAIN D_Bool AS SMALLINT DEFAULT 0 NOT NULL
CHECK (VALUE IN 0, 1) ;
Note that DEFAULT fires only on an insert and only if the column is not
included in the insert query specification.
CREATE DOMAIN D_Bool AS SMALLINT
CHECK (VALUE IS NULL OR VALUE IN (0, 1));
heLen