Re: Integrity constraint
Date: Tue, 03 Feb 2009 12:46:32 +0100
Michael Rauscher schreef:
> vm22 wrote:
>> Hi, >> >> I have a developer who has written the following code to delete some >> records: >> >> 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?
> Because a corresponding record exists in table Z?
> Hint: De Morgan's laws
Is there a column named ID in y? If not, the statement will not fail with any syntax errors, but always find corresponding records in y. To check this, change your statement to:
DELETE FROM x
WHERE x.id NOT IN (SELECT y.id
AND x.id NOT IN (SELECT z.id
If there's no column id in y, you'll get a syntax error.
Other possibility: Y_FK is not on column ID... can't see that from here.
Shakespeare Received on Tue Feb 03 2009 - 05:46:32 CST