Subject Re: [firebird-support] FK violation when creating FK, but tables are empty!
Author Martijn Tonies
Hello Mark,

>> I'm trying to create a Foreign Key Constraint and I'm getting the
>> following
>> error:
>>
>> violation of FOREIGN KEY constraint "FK_LOG_ITEM_LOG" on table
> "LOG_ITEM"
>> Foreign key reference target does not exist
>>
>>
>> However, both tables LOG (master) and LOG_ITEM (detail) are empty!
>>
>>
>> Statement:
>> ALTER TABLE LOG_ITEM ADD CONSTRAINT FK_LOG_ITEM_LOG
>> FOREIGN KEY (LOGID) REFERENCES "LOG"
>> (LOGID)
>> ON DELETE CASCADE
>> ON UPDATE NO ACTION
>>
>>
>> Firebird version:
>> WI-V6.3.0.26074 Firebird 2.5
>>
>>
>> Any clue?
>
> Doesn't this error indicate that the table or column you are referencing
> doesn't exist? Did you commit the LOG table, is the table actually called
> "LOG", and not "Log", does the column LOGID exist?

The table is LOG, with column LOGID as the PK.

Unknown columns gets error:

unsuccessful metadata update
could not find UNIQUE or PRIMARY KEY constraint in table LOG with specified
columns

Unknown table gets error:

unsuccessful metadata update
Table LOG2 not found


The statement was generated by Database Workbench, I added quotes because
I thought maybe there was a bug in DBW and it would help, same result
though.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!