Re: Integrity constraint
Date: Thu, 05 Feb 2009 19:05:22 -0600
> On Feb 4, 6:54 pm, Michael Austin <maus..._at_firstdbasource.com> wrote:
>> vm22 wrote:
>>> I have a developer who has written the following code to delete some
>>> DELETE FROM x
>>> WHERE id NOT IN (SELECT id
>>> FROM y)
>>> AND id NOT IN (SELECT id
>>> FROM z);
>>> ORA-02292: integrity constraint (Y_FK) violated - child record found
>>> When there is already a clause in my delete to state do not delete
>>> records that are found in table Y, why do I get the integrity
>>> constraint error message?
>> Very simple here. You are deleting something in X that must exist
>> because it is referenced on X by Y_FK.
>> In X:
>> in Y
>> if you delete 3 in X and it is a FK for Y (MUST exist) then you will get
>> this error.
>> It is called REFERENTIAL INTEGRITY.
[TOP POSTING FIXED]
> I have a NOT IN clause.
there is obviously something Oracle THINKS that your delete will violate the constraint.
[just read your other post that you are adding data at the same time you are trying to run this delete]
is ID a unique column?
what is the result of
I generally test my deletes first to ensure I know what I am deleting (having to recover a db because of an error in my script is NOT much fun.)
select * from x
WHERE id NOT IN (SELECT id
AND id NOT IN (SELECT id
FROM z); Received on Thu Feb 05 2009 - 19:05:22 CST