Subject Re: [firebird-support] Foreign Key and NOT NULL
Author Helen Borrie
At 03:39 PM 17/11/2003 +0200, you wrote:
>When moving data from Paradox tables to firebird. I always get an INTEG_23
>constrating error on the following table:
>
>CREATE TABLE Owner /* Wp */
>(
>OwIDSQ INTEGER NOT NULL ,
>CityVBSQ INTEGER NOT NULL ,
>OwVBSQ INTEGER ,
>OwName VARCHAR(120) NOT NULL ,
>
>PRIMARY KEY (OwIDSQ) ,
>FOREIGN KEY (CityVBSQ) REFERENCES City (CityIDSQ) ON DELETE CASCADE ,
>FOREIGN KEY (OwVBSQ) REFERENCES Whitepage (OwIDSQ) ON DELETE CASCADE
>) ;
>
>OwVBSQ may reference another record in the same table but must not. I gave
>OwVBSQ a NOT NULL constraint so it could take NULL values for those records
>where this self referencing does not apply. But as soon as I enter a record
>where OwVBSQ is NULL I get an error message. What is wrong ?

NOT NULL means "NULL is not permitted". That's why you get the error. :-)

Unfortunately, you cannot remove a NOT NULL constraint. You have to create
a new temporary column *without* the constraint, commit, copy the data from
OwVBSQ into it, commit, drop OwVBSQ, commit, create OwVBSQ without the
constraint, commit, copy the data from the temp col into OwVBSQ,
commit; then drop the temp column.

heLen