Oracle 11g R2:ORA-02291:integrity constraint violated -parent key not found
823949Dec 14 2010 — edited Dec 15 2010I 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.