Re: Integrity constraint

From: vm22 <vivekmarwaha_at_gmail.com>
Date: Wed, 4 Feb 2009 12:47:05 -0800 (PST)
Message-ID: <babf3e5e-a1f6-4bf9-a5d7-f56774a021b9_at_i24g2000prf.googlegroups.com>


I have a NOT IN clause.

On Feb 4, 6:54 pm, Michael Austin <maus..._at_firstdbasource.com> wrote:
> 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 - 14:47:05 CST

Original text of this message