Reputation: 21
When I tried to delete something in my DB2, this message appeared:
-532 THE RELATIONSHIP constraint-name RESTRICTS THE DELETION OF ROW WITH RID X rid-number
What does this error mean and how can I resolve it?
What is the correct way to delete from my DB2? This is how I'm doing it now:
DELETE FROM LN_WIP WHERE NUM IN (500018605, 500018605, 500018605 ); –
Upvotes: 1
Views: 6174
Reputation: 48865
Yep, you are most likely trying to delete a parent row, that has children rows. Please read IBM Error Codes.
There is a foreign key relationship that is preventing the deletion of the parent row.
To find out which FK is preventing you from deleting the row, first you can list all the exported foreign keys in that table:
select
substr(tabname,1,20) table_name,
substr(constname,1,20) fk_name,
substr(REFTABNAME,1,12) parent_table,
substr(refkeyname,1,20) pk_orig_table,
fk_colnames
from syscat.references where reftabname = 'LN_WIP';
Please post the result of this query. One of these is the culprit FK.
Upvotes: 3