Subject | Check constraint and null question |
---|---|
Author | Scott Bussinger |
Post date | 2003-06-05T05:20:45Z |
Please help a newbie to SQL out and explain something for me. I'm trying
to migrate an application written using Paradox files over to Firebird.
I've got 1.5 RC2 loaded in a Win98 box and I'm using the Interbase
DataPump and Database Desktop to play with everything and move some
sample data across.
The problem is that I have a table defined like this:
CREATE TABLE "COUNTY" (
"COUNTY" VARCHAR(15) NOT NULL,
"STATE" VARCHAR(2) NOT NULL,
"NAME" VARCHAR(20) NOT NULL,
"REGION" VARCHAR(9) NOT NULL,
"TAX" FLOAT CHECK ("TAX" >= 0 AND "TAX" <= 0.1),
"NORTHEAST" CHAR(1),
"NORTHWEST" CHAR(1),
"SOUTHEAST" CHAR(1),
"SOUTHWEST" CHAR(1)
);
The problem is that I can't insert a row that has a NULL "TAX" field
because I get a check error (specifically "Operation violates CHECK
constraint INTEG_25 on view or table COUNTY"). I thought I understood it
that any operation involving a NULL value has an unknown result and that
a check constraint only watches for a FALSE result so a NULL should be
allowed here shouldn't it?
Thanks for helping me out!
to migrate an application written using Paradox files over to Firebird.
I've got 1.5 RC2 loaded in a Win98 box and I'm using the Interbase
DataPump and Database Desktop to play with everything and move some
sample data across.
The problem is that I have a table defined like this:
CREATE TABLE "COUNTY" (
"COUNTY" VARCHAR(15) NOT NULL,
"STATE" VARCHAR(2) NOT NULL,
"NAME" VARCHAR(20) NOT NULL,
"REGION" VARCHAR(9) NOT NULL,
"TAX" FLOAT CHECK ("TAX" >= 0 AND "TAX" <= 0.1),
"NORTHEAST" CHAR(1),
"NORTHWEST" CHAR(1),
"SOUTHEAST" CHAR(1),
"SOUTHWEST" CHAR(1)
);
The problem is that I can't insert a row that has a NULL "TAX" field
because I get a check error (specifically "Operation violates CHECK
constraint INTEG_25 on view or table COUNTY"). I thought I understood it
that any operation involving a NULL value has an unknown result and that
a check constraint only watches for a FALSE result so a NULL should be
allowed here shouldn't it?
Thanks for helping me out!