0

I have table named VARIANT_LINK_BUILD_CHANGE where primary key column name is VARIANT_LINK_BUILD_CHANGE_OID and foreign key is also in same table named SWAP_VL_BUILD_CHANGE_OID.

The data looks like this:

VARIANT_LINK_BUILD_CHANGE_OID    MOD_TYPE     SWAP_VL_BUILD_CHANGE_OID
    22269                         ADD           (null)
    27510                         DELETE        (null)
    32399                         DELETE        (null)
    32400                         MODIFY        (null)

Here , when I try to delete the above records using the query

DELETE FROM VARIANT_LINK_BUILD_CHANGE 
WHERE VARIANT_LINK_BUILD_CHANGE_OID IN  (22269, 27510, 32399, 32400);

I get this error:

[Code: -532, SQL State: 23504] THE RELATIONSHIP FK_VARIANT_LINK_BUILD_CHANGE_SWAP RESTRICTS THE DELETION OF ROW WITH RID X'000001270C'. SQLCODE=-532, SQLSTATE=23504, DRIVER=4.28.11

I am not sure why getting the above error since foreign key values are null. Can anyone help with this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Rooban
  • 248
  • 1
  • 15
  • 3
    If I understand it correctly, column `SWAP_VL_BUILD_CHANGE_OID` has a FK constraint that references `VARIANT_LINK_BUILD_CHANGE_OID`. If so there must be some row where `SWAP_VL_BUILD_CHANGE_OID IN (22269, 27510, 32399, 32400)` that prevents the deletion of at least one of the rows you show – nfgl Aug 10 '22 at 07:53
  • Check if the FK is defined appropriately for the requirements (whether by default or by explicit syntax), sometimes `on delete set null` is helpful, but much depends on the application . – mao Aug 10 '22 at 08:17

0 Answers0