I need to update a column in two tables that are joined by a primary/foreign key. My problem is that when I try to update either table separately, I get either of the following (dependant upon which table I try and update):
ORA-02292: integrity constraint (URMS.EMSR_EMS_FK) violated - child record found
or
ORA-02291: integrity constraint (URMS.EMSR_EMS_FK) violated - parent key not found
Is there a way to update both tables at exactly the same time with the new value? A solution I've found is to copy the existing rows and insert these as new rows, which can then be updated -- the old rows can then be deleted.
Is this the only solution or is there an easier way around this?
If you are updating a parent table, you cannot modify a primary key for which dependent rows exist. Changing the key violates referential constraints for dependent tables and leaves some rows without a parent.
You have a few options as workarounds.
NOT NULL
constraintHowever there is no way to create a statement that updates both at the same time in Oracle as you might have with ON UPDATE CASCADE
in some other databases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With