Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

remove inactive entitlements from Entitlement_values

Vyanamadala
New Contributor
New Contributor

We are trying to remove few duplicate inactive entitlements from Entitlement_values through db script.

But are failing with below error

ERROR 1451 (23000) at line 1 in file: 'datafix_stmt4_updated.sql': Cannot delete or update a parent row: a foreign key constraint fails (`saviyntdb`.`entitlement_values`, CONSTRAINT `FK469E7074BE8E85C9` FOREIGN KEY (`REFERENCED_ENTITLEMENT`) REFERENCES `entitlement_values` (`ENTITLEMENT_VALUEKEY`))

Note: we deleted unused 400 duplicate inactive entitlements with the same script  (delete from entitlement_values where entitlement_valuekey in ('','','');) and entitlement_valuekey  values are filtered making sure those entitlement_valuekey   is not referenced in any of the below

account_entitlements1,role_entitlements,entitlementmap,arstasks,entitlement_values_history,certification_entitlement_value,certification_account_entitlement1_status  

1 REPLY 1

rushikeshvartak
All-Star
All-Star

Deleting data from database in not best practise it can cause issue in future.

you can disable foreign key checks temporarily

-- Disable foreign key checks
SET FOREIGN_KEY_CHECKS = 0;

-- Perform your actions here
DELETE FROM parent_table WHERE id = 123;

-- Re-enable foreign key checks
SET FOREIGN_KEY_CHECKS = 1;


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.