Subject Creating Foreign keys
Author Riho-Rene Ellermaa
I have table MASS_PERSONS which has foreign key to MASSGROUPS table.
ALTER TABLE MASS_PERSONS_LV ADD CONSTRAINT FK_MASSPERS FOREIGN KEY (GR_ID) REFERENCES MASSGROUPS(ID) ON UPDATE CASCADE ON DELETE

Now I wanted to add another table (MASS_PERSONS_LV) and create similar foreign key, but I get error "Object MASSGROUPS is in use".
Is it not possible to have 2 tables, both having foreign key linked to the same table?


CREATE TABLE MASS_PERSONS_LV (
GR_ID INTEGER NOT NULL,
NAME VARCHAR(30) CHARACTER SET WIN1252,
ACCOUNT VARCHAR(16) CHARACTER SET WIN1252,
REGNO VARCHAR(15) CHARACTER SET WIN1252,
BANK VARCHAR(12) CHARACTER SET WIN1252,
AMOUNT NUMERIC(15,2)
);
ALTER TABLE MASS_PERSONS_LV ADD CONSTRAINT FK_MASSPERS_LV FOREIGN KEY (GR_ID) REFERENCES MASSGROUPS(ID) ON UPDATE CASCADE ON DELETE CASCADE;

Riho-Rene Ellermaa
senior programmer