Skip to Main Content

Oracle Database Discussions

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!

Oracle 11g R2:ORA-02291:integrity constraint violated -parent key not found

823949Dec 14 2010 — edited Dec 15 2010
I have a table, say TABLEA which has two columns marked as a foreign key, referencing a two column primary key in another table TABLEB.

i.e.: TABLEA (aid,sid) = TABLEB(id,sid)

I've even inserted data into both tables that honor the referential key.

However, when I run an update on the TABLEA as follows:

update TABLEA
set aid = 'xyz' //xyz exists in TABLEB.id
where id = 'abc'

I get the error ORA-02291:integrity constraint (TABLEA foreign key name) violated - parent key not found.

Strangely enough if I run the following sql:

update TABLEA
set aid = 'xyz' //xyz exists in TABLEB.id
,sid = 'sid from tableb' // 'sid from tableb' exists in TABLEB.sid for the same row.
where id = 'abc'

I dont get the error.

Further more, after I commit this trans., I am able to run the first query without any error, i.e.:
update TABLEA
set aid = 'xyz' //xyz exists in TABLEB.id
where id = 'abc'

What gives? Why such strange behaviour?

Note, I only see this behavior when I'm running my application with Oracle 11g R2 with only a few tables. I've used and am using the same application (separate instance) with Oracle 10g, without any such issues.

Any help would be much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2011
Added on Dec 14 2010
4 comments
696 views