Subject | Re: [firebird-support] Foreign key violation - but why??? |
---|---|
Author | Bjoern Reimer |
Post date | 2005-03-08T11:27:47Z |
Hi,
sorry, 've forgotten to post the primary key definitions.
ALTER TABLE XPERT_ZAHLUNGEN ADD CONSTRAINT PK_XPERT_ZAHLUNGEN PRIMARY KEY (ID);
and
ALTER TABLE XPERT_ANMELDUNGEN ADD CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY (ANMELDUNG_ID);
are present of course.
LF> Bjoern,
LF> Bjoern Reimer schrieb:
LF> CREATE TABLE XPERT_ANMELDUNGEN (
LF> ANMELDUNG_ID BIGINT NOT NULL,
LF> PRUEFUNGSART_ID INTEGER NOT NULL,
LF> PERSON_ID INTEGER NOT NULL,
LF> XP_TERM_ID INTEGER NOT NULL,
LF> ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL,
LF> /* ADD THIS LINE */
LF> CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY ( ANMELDUNG_ID )
LF> );
LF> Otherwise your ForeignKey definition should fail with an error like:
LF> unsuccessful metadata update
LF> could not find UNIQUE INDEX with specified columns
LF> Luc.
LF> Yahoo! Groups Links
Mit freundlichen Grüßen
Björn Reimer
--
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
sorry, 've forgotten to post the primary key definitions.
ALTER TABLE XPERT_ZAHLUNGEN ADD CONSTRAINT PK_XPERT_ZAHLUNGEN PRIMARY KEY (ID);
and
ALTER TABLE XPERT_ANMELDUNGEN ADD CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY (ANMELDUNG_ID);
are present of course.
LF> Bjoern,
LF> Bjoern Reimer schrieb:
>> Hi,LF> You have to define a primary key on your table(s).
>>
>> (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
>> );
LF> CREATE TABLE XPERT_ANMELDUNGEN (
LF> ANMELDUNG_ID BIGINT NOT NULL,
LF> PRUEFUNGSART_ID INTEGER NOT NULL,
LF> PERSON_ID INTEGER NOT NULL,
LF> XP_TERM_ID INTEGER NOT NULL,
LF> ZAHLUNGSSTATUS SMALLINT DEFAULT 0 NOT NULL,
LF> /* ADD THIS LINE */
LF> CONSTRAINT PK_XPERT_ANMELDUNGEN PRIMARY KEY ( ANMELDUNG_ID )
LF> );
LF> Otherwise your ForeignKey definition should fail with an error like:
LF> unsuccessful metadata update
LF> could not find UNIQUE INDEX with specified columns
LF> Luc.
LF> Yahoo! Groups Links
Mit freundlichen Grüßen
Björn Reimer
--
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