Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-02291: integrity constraint violated, when parent row is there

3047549Feb 2 2016 — edited Feb 3 2016

Hi,

can somebody give me an idea because I lost 3 hours now on this and still no progress:

Parent Table: T1, PK: col1, col2......... row with col1=1, col2 = 18 is there ......there are also more columns there......but not important

Child Table : T2 : FK : col1, col2.....there is a row with col1=NULL, col2=18

I want to :

update T2 set col1=1 where col2=18

ORA-02291: integrity constraint violated, not possible

BUT !...the following works:

update T2 set col1=1, col2=col2  where col2=18



also, the following works:


update T2 set col2=col2 where col2=18


and now


update T2 set col1=1 where col2=18


works !!!




if I do:


create table T3 as select * from T2


and then add FK from T3 to T1


then

update T3 set col1=1 where col2=18



works !




Important is that also one another FK from T2 that points to the third table DOES NOT WORK......has the same behavior like the explained case


I tried to compare rows in user_constraints and user_oncs_columns for T2 and T3....and everything looks the same..but still teh behavior is different




Anybody has any idea why my initial statement


update T2 set col1=1 where col2=18


does not work ???

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2016
Added on Feb 2 2016
10 comments
4,200 views