Subject | on delete set null |
---|---|
Author | Nick Upson |
Post date | 2003-07-16T12:08:23Z |
I don't know if I read the manual wrong or this is a bug. When I delete a
row in the
employee table the corresponding rows in the company table are not set to
null but
I get the "attempt to violate a foreign key" message. what's wrong?
CREATE TABLE COMPANY (
COMPANY_U INTEGER NOT NULL,
EMPLOYEE_U INTEGER,
COMPANYNAME VARCHAR(40) NOT NULL,
CONSTRAINT COMPANY_PK PRIMARY KEY (COMPANY_U),
CONSTRAINT COMPANY_UC1 UNIQUE (COMPANYNAME)
);
ALTER TABLE COMPANY ADD CONSTRAINT COMPANY_FK5 FOREIGN KEY (EMPLOYEE_U)
REFERENCES EMPLOYEE(EMPLOYEE_U) ON DELETE SET NULL;
_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today!
http://www.msn.co.uk/messenger
row in the
employee table the corresponding rows in the company table are not set to
null but
I get the "attempt to violate a foreign key" message. what's wrong?
CREATE TABLE COMPANY (
COMPANY_U INTEGER NOT NULL,
EMPLOYEE_U INTEGER,
COMPANYNAME VARCHAR(40) NOT NULL,
CONSTRAINT COMPANY_PK PRIMARY KEY (COMPANY_U),
CONSTRAINT COMPANY_UC1 UNIQUE (COMPANYNAME)
);
ALTER TABLE COMPANY ADD CONSTRAINT COMPANY_FK5 FOREIGN KEY (EMPLOYEE_U)
REFERENCES EMPLOYEE(EMPLOYEE_U) ON DELETE SET NULL;
_________________________________________________________________
Express yourself with cool emoticons - download MSN Messenger today!
http://www.msn.co.uk/messenger