Foreign key issue
Posted in 2010
Topics: Stored Procedures & SPL, Triggers, Constraints & Referential Integrity
We have a table with one row only and it is referred in two tables through foreign keys i..e, two child tables. A stored procedure deletes a few record and insert some records on daily basis. For last couple od days we are getting below exception " Missing key in referenced table for referential constraint (mcp.r1535_6450)" but there is nothing wrong with values. For a workaround we drop the foreign key before procedure execution and recreate after the procedure get executed. How can we figure out what would be wrong with index or anything else?
I would review the SPL logic to be sure that you aren't trying to delete a row from the base table when it still has rows in the children tables. Since it is working when you remove the foreign keys it seems that a timing issue of some kind could be the cause of your problems.