Subject Foreign key violation - but why???
Author Bjoern Reimer
Hi,

(Firebird 1.5.1 CS on Linux)

Here is my situation:

Two tables with one record each. I want to create a foreign key
constraint from one to the other.


CREATE TABLE XPERT_ANMELDUNGEN (
ANMELDUNG_ID BIGINT NOT NULL,
PRUEFUNGSART_ID INTEGER NOT NULL,
PERSON_ID INTEGER NOT NULL,
XP_TERM_ID INTEGER NOT NULL,
ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL
);

INSERT INTO XPERT_ANMELDUNGEN
(ANMELDUNG_ID,PRUEFUNGSART_ID,PERSON_ID,XP_TERM_ID,ZAHLUNGSSTATUS)
VALUES (1,1,6,6,0);


CREATE TABLE XPERT_ZAHLUNGEN (
ID BIGINT NOT NULL,
REF_ANMELDUNG_ID BIGINT,
REF_ZAHLUNGSART SMALLINT,
ZEITPUNKT TIMESTAMP NOT NULL
);


INSERT INTO XPERT_ZAHLUNGEN (ID,REF_ANMELDUNG_ID,REF_ZAHLUNGSART,ZEITPUNKT) VALUES (30,1,1,'7-MAR-2005 00:00:00');


And

alter table XPERT_ZAHLUNGEN add constraint
FK_XPERT_ZAHLUNGEN_REF_ANMELDUN foreign key (REF_ANMELDUNG_ID)
references XPERT_ANMELDUNGEN(ANMELDUNG_ID)

returns me

violation of FOREIGN KEY constraint "".
violation of FOREIGN KEY constraint "PK_XPERT_ANMELDUNGEN" on table "XPERT_ANMELDUNGEN".


I've the same result in this table with REF_ZAHLUNGSART which points
to another table of course....

I've tried it without any records in XPERT_ZAHLUNGEN with the same
result...

Any ideas?



Björn

--
Björn Reimer -- RRZE
Tel: +49-9131 - 85-27809
Fax: +49-9131 - 302941
Martensstr. 1 / 2.021
D - 9 1 0 5 8 Erlangen
www.rrze.uni-erlangen.de