Re: Integrity constraint

From: Michael Austin <maustin_at_firstdbasource.com>
Date: Wed, 04 Feb 2009 12:54:16 -0600
Message-ID: <rxlil.15397$YU2.1109_at_nlpi066.nbdc.sbc.com>



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?
>
>
>
>

Very simple here. You are deleting something in X that must exist because it is referenced on X by Y_FK.

Example:

In X:
1
2
3
4

in Y

a,b,c,1
a,d,e,2
a,b,c,3

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. Received on Wed Feb 04 2009 - 12:54:16 CST

Original text of this message