This content has been marked as final. Show 5 replies
You can use PRAGMA EXCEPTION_INIT ( use the error code (ORA-02291)):
declare parent_not_found exception; pragma exception_init(parent_not_found, -2291); begin -- your_code and stuff etc. exception when parent_not_found then -- handle the error end;
The error code you use in your subject, refers to another error message:
ORA-02291: integrity constraint (string.string) violated - parent key not found
Cause: A foreign key value has no matching primary key value.
Action: Delete the foreign key or add a matching primary key.
ORA-02292: integrity constraint (string.string) violated - child record found
Cause: attempted to delete a parent key value that had a foreign key dependency.
Action: delete dependencies first then parent or disable constraint.
It's up to you to pick the right one ;)