Error: Unhandled Exception:Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
What causes the error: Unhandled Exception:Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
Cause: There is a known issue in Deltek Cobra that allows it to insert ‘duplicate’ records in the WST_DIR in certain circumstances. ‘Duplicate’ because those records are keyed on a unique id value (a number), so the unique ids are not duplicated, but the name of the file and the file type are duplicated.
So you might have two records like this:
This doesn’t cause a problem for the unique index on the table but causes a problem for Cobra as soon as it tries to load the program records (or the duplicates might be in calendar files, rate files, etc).
Resolution: The steps to find and resolve the issue are the following.
1. Run this query from SQL Server to identify whether duplicates like this exist:
SELECT DIR_ID, TABLE_TYPE, COUNT(*) FROM WST_DIR GROUP BY DIR_ID, TABLE_TYPE HAVING COUNT(*) > 1
2. If the step above returns no records then no duplicates are found in the WST_DIR table.
This indicates that your issue has another cause. It is recommended that you submit a case to Deltek Customer Care and include the logs generated by the error for examination. If the query does turn up a record, you will need to select out those records to inspect the DIR_UID values:
SELECT * FROM WST_DIR WHERE DIR_ID = ‘value1’ AND TABLE_TYPE = ‘value2’
3. Now, you could delete just one of these records, but there may be security records which relate to one of them, so you should also select from WST_ACL to see if either of these records has related entries:
SELECT DIR_UID FROM WST_ACL WHERE DIR_UID IN ( SELECT DIR_UID FROM WST_DIR WHERE DIR_ID = ‘value1’ and TABLE_TYPE = ‘value2’)
4. This will give you the DIR_UID of the record you want to keep in WST_DIR, you can then delete the other duplicate.
To read more Deltek Cobra articles click here