Home » SQL & PL/SQL » SQL & PL/SQL » ORA-02291: integrity constraint violated - parent key not found
ORA-02291: integrity constraint violated - parent key not found [message #251968] |
Tue, 17 July 2007 10:20  |
poratips
Messages: 345 Registered: April 2005 Location: IL
|
Senior Member |
|
|
Hi,
I am running following INSERT and getting parent key not found error.
ERROR at line 1:
ORA-02291: integrity constraint (O_ITEM_REL_FK1) violated - parent key not found
o_item (parent) and o_item_REL (child) has parent child relationship.
Both id i am generating through sequence and I have to load id values in both table same time means when i generate sequence in o_item table then same value i have to load in o_item_REL table. It was running fine and suddenly it's throwing this error.
My where clause running fine and without child table insert it's also running fine. I have also tried to load data into dev from prod but it also throwing error in development.
SQL
INSERT ALL
INTO o_item (o_item_id, PROD_ID, PRICE, L_Total, Q_ORDER, Q_SHIP, L_NUM)
VALUES ('LD_'||o_item_seq.NEXTVAL, PRODUCT_ID, PRICE, L_Total, Q_ORDER, Q_SHIP, L_NUM)
INTO o_item_REL (O_ID, o_item_id)
VALUES (o_id, 'LD_'||o_item_seq.CURRVAL)
SELECT A.PROD_ID, D.O_id, A.PRICE, A.L_Total, A.Q_ORDER, Z.Q_SHIP, A.L_NUM
FROM o_load A, O_item C, o_item_REL B, ord D
WHERE A.prod_id = C.prod_id
AND A.j_ref_num = C.n_ord_id
AND A.n_ord_id = D.n_ord_id
AND C.o_item_id = B.o_item_id
AND (A.N_ORD_ID not in (select F.n_ord_id from o_item F where F.n_ord_id = a.n_ord_id)
OR (A.N_ORD_ID in (select F.n_ord_id from o_item F where F.n_ord_id = a.n_ord_id)
AND A.prod_id not in (select F.prod_id from o_item F where F.n_ord_id = a.n_ord_id)
)
)
/
commit;
Please let me know, appreciated.
Thanks,
[Updated on: Tue, 17 July 2007 10:40] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: ORA-02291: integrity constraint violated - parent key not found [message #252313 is a reply to message #252171] |
Wed, 18 July 2007 10:32   |
poratips
Messages: 345 Registered: April 2005 Location: IL
|
Senior Member |
|
|
Thanks, I read somewhere in other forums that insert all" is not atomic after all. I am just looking alternate method like trigger or pl/sql if you guys have any better solution but i am getting this error.
This issue is an open bug:
Quote: | <bug:2891576> MULTI TABLE INSERT (INSERT ALL) FAILS WITH ORA-2291
Moderator: Due to copyright restriction, the rest of the quoting is deleted. Please refer to the original document.
|
Thanks for your help.
[Updated on: Thu, 19 July 2007 03:11] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: ORA-02291: integrity constraint violated - parent key not found [message #426787 is a reply to message #251968] |
Mon, 19 October 2009 11:22   |
rosma
Messages: 2 Registered: October 2009 Location: selangor
|
Junior Member |

|
|
i got this problem(ORA-02291: integrity constraint (SMP.OL_PERS_ID_ADDR_REFER) violated - parent key not found)...anyone can help me....plz..i dont know what to do coz i'm new in programming..
this is a sql for insert----->>>>>
<!------start----->
String insertAddressInt = "INSERT INTO ol_adm_person_address_temp " +
" (padd_id, "+
" addt_code_addtype, " +
" coun_id_country, " +
" pers_id, " +
" padd_addr1, " +
" padd_postcode, " +
" padd_addr2, " +
" padd_city, " +
" padd_tel, "+
" padd_fax, " +
" padd_createddate, " +
" padd_createdby, " +
" padd_email, " +
" padd_negeri, "+
" padd_addr3, " +
" padd_hp_no, "+
" padd_iscorresadd " +
" ) " +
"VALUES (adm_person_address_SEQ.NEXTVAL, ?, ?, ?, ?, ?, ?, ?, ?,?,sysdate,?, ?, ?, ?, ?, ?) " ;
String insertAddressObjInt[][] = {
{"str","CURRENT"},
{"int",cor_country},
{"int",persid},
{"str",cor_add1},
{"str",cor_add2},
{"str",cor_poscode},
{"str",cor_city},
{"str",cor_tel},
{"str",cor_fax},
{"int",persid},
{"str",cor_email},
{"str",cor_state},
{"str",cor_add3},
{"str",cor_hp},
{"int",is_correspondence}
};
<!-----------end----------------->
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Jun 07 04:53:06 CDT 2025
|