Subject Foreign Key -- Alter Table fails -- could not find UNIQUE INDEX with specified columns
Author David K. Trudgett
I'm doing an automatic conversion of a 13000 line Oracle SQL script
into SQL that IB/FB understands. Everything was working fine until
recently, when a change made to the Oracle script was made.

The FB version of the script generates a metadata update error that, on
the face of it, seems to be misleading, because what it says is not
true.

The problem happens with this bit of SQL:

ALTER TABLE TABLE1
ADD CONSTRAINT FK_TAB1TAB2
FOREIGN KEY (COL1, COL2)
REFERENCES TABLE2 (COL1, COL2);

The error:

Statement failed, SQLCODE = -607

unsuccessful metadata update
-could not find UNIQUE INDEX with specified columns

There is definitely a unique index over just those two columns in both
of the tables. Inspection of the metadata using Marathon proves that.

Does anyone have an idea what might be causing this error? It's not a
typo in the column names -- I've checked that about four times already
:-).

I'm using Firebird 1.0 CS on Linux

Thanks.

David Trudgett