Subject | Re: NOT NULL constraint not being enforced by Firebird |
---|---|
Author | dr_bentonquest |
Post date | 2006-06-10T16:41:04Z |
> > This is a known issue.the
> >
> > If you add a not null field to a table, you need to remember to set
> > values to all pre-existing records in that field. The existing records
> > are not checked when such a constraint is added. The values are
> > policed basically in before insert or update triggers.
> I've known this issue (adding not null columns WITHOUT a default value)
> and I've tried to test it yesterday. Benton metioned that he defined
> field with "DEFAULT 0 NOT NULL". I tried this on my system and FirebirdNot that I recall. I must have used a statement like ALTER TABLE
> behaved like it should: it pre-set the value 0 into the column.
> Here is what I did via DDL, works flawlessly:
> ALTER TABLE TESTNULLS ADD TESTFIELD NUMERIC(9,2) DEFAULT 0 NOT NULL;
>
> Benton, could it be that you added the "DEFAULT 0" later on, via some
> tool like IBExpert?
DETALLENOM ADD DEDXTRA NUMERIC(9,2) DEFAULT 0 NOT NULL.
Sincere thanks to all for your insight. I have solved the problem by
including the fields in the INSERT field list and providing a 0 as the
field value.
Best Regards,
-Benton