Subject I can't drop foreign key.
Author 渡辺
Hi.

I am using FireBird2.5.3,and a dataBase is updated from 2.2, and the database was updated from 1.5.

The database have about 150 tables and just one Foreign key.

The Foreign key is from "hachu"table to "parts"table.

This is a part of definition of the Tables.

(ISQL showed these informations)

SQL> show table parts;
OPERATIONCODE VARCHAR(100) Nullable
PARTSID INTEGER Not Null
PRODUCTCODE VARCHAR(100) Nullable
CONSTRAINT INTEG_152:
Primary key (PARTSID)

SQL> show table hachu;
HACHUDATE DATE Nullable
HACHUID INTEGER Not Null
HACHUNO VARCHAR(10) Nullable
HSU INTEGER Nullable
CONSTRAINT FKHACHUTOPARTS:
Foreign key (PARTSID) References PARTS (PARTSID) On Delete Set Null

I want to drop the Foreign key.
But when I tried to drop the Foreign key,FireBird display this messages,
and I can't drop the Foreign key.

SQL> alter table hachu drop constraint fkhachutoparts;

Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot delete
-INDEX FKHACHUTOPARTS
-there are 1 dependencies

I deleted all records of both table,
and I dropped all triggers of both table.

I also can't drop these tables.

SQL> drop table hachu;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot delete
-INDEX FKHACHUTOPARTS
-there are 1 dependencies
SQL> drop table parts;
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-ERASE RDB$RELATION_CONSTRAINTS failed
-action cancelled by trigger (1) to preserve data integrity
-Cannot delete PRIMARY KEY being used in FOREIGN KEY definition.

I can't understand why I can't drop the Foreign key.

Any advice, any suggestion is appreciated.

Nobuo Watanabe