Subject Error on Foreign Key creation
Author Chef
Sorry for not changing the subject in my previous meessage !!

- - - - -

Hi all !

I have a database used since 4 years with about 70 tables
with many foreign keys defined in the first create database script.

I always did backup/restore the db after some metadata changes.

I can add new tables but if I try to define a new foreign key
referencing a primary key field of one of the old tables using a statement
like this

>>
ALTER TABLE BEHARTEN ADD FOREIGN KEY (BEH_ID_PLACE) REFERENCES PLACES
(PL_ID_PLACE);
<<

then I get this eror msg:

>>
ISC ERROR CODE:335544351

ISC ERROR MESSAGE:
unsuccessful metadata update
STORE RDB$REF_CONSTRAINTS failed
action cancelled by trigger (1) to preserve data integrity
Name of Referential Constraint not defined in constraints table.

STATEMENT:
TIB_DSQL: "IB_Script."
<<

Note that BEH_ID_PLACE is NOT NULL.
Sometimes creating a foreign key works sometimes it doesn't.
It doesn't depend on having data in the tables - I even can't create
some of the desired foreign keys in an empty database.

I have studied the LangRef and DevGuide and looked into the system tables
but I couldn't find anything meaningful.

BTW: eg I have several tables with the field "ID_CLIENT". Using Jason
Wharton's IB_WISQL I searched in "RDB$CHECK_CONSTRAINTS" in field
"RDB$TRIGGER_NAME" for "ID_CLIENT" but it yielded no results !
But searching for "ID_CLIENT%" returned 3 records.
Does the referenced field need to have a unique name in the db ??

Environment:
Latest IBObjects version (IB_WISQL), latest Firebird (it didn't work with
good old
IB 5.6, too), WinNT 4.0 SP 5 or Win2k SP 1.

Can anybody help me with this ? I desperately need help with this !

TIA,
Markus