Subject | Re: [firebird-support] Foreign Key - Problem with Unique constraint |
---|---|
Author | Helen Borrie |
Post date | 2012-09-04T11:19:02Z |
At 10:25 PM 4/09/2012, Cam wrote:
./heLen
>FB Version 2.5.1.26351It must be a unique CONSTRAINT. Just defining a unique index is not enough.
>
>I have a table (test) with a unique constraint on a field ID_NUMERIC.
>CREATE TABLE TEST
>( ID BIGINT NOT NULL,
> ID_NUMERIC INTEGER NOT NULL,
> CONSTRAINT PK_TEST PRIMARY KEY (ID)
>);
>CREATE UNIQUE ASC INDEX UI_ID_NUMERIC ON TEST (ID_NUMERIC);
>
>
>Table TESTFK is
>CREATE TABLE TESTFK
>(
> ID BIGINT NOT NULL,
> NUMERIC_ID INTEGER NOT NULL,
> DESCR VARCHAR( 21) COLLATE NONE,
> CONSTRAINT PK_TESTFK PRIMARY KEY (ID)
>);
>
>If I try to add a FK ..
>ALTER TABLE TESTFK ADD CONSTRAINT TESTFK_FK
> FOREIGN KEY (NUMERIC_ID) REFERENCES TEST(ID_NUMERIC)
> ON DELETE CASCADE
> ON UPDATE CASCADE;
>
>I get the following error.
>Script Error:
>unsuccessful metadata update
>could not find UNIQUE or PRIMARY KEY constraint in table TEST with
>specified columns
>I'm sure this used to work?Nope, it never did.
./heLen