If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > ora-02291 integrity constraint

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-05-12, 09:52
lerono lerono is offline
Registered User
 
Join Date: Mar 2009
Posts: 1
ora-02291 integrity constraint

I am working on a project that handles customer orders and inventory. I am stuck on one part, I keep getting the ORA-02291 error. The column causing the problems is the CustOrderID. Here's what I have:

This statement uses a sequence to create a new CustOrderID
Code:
select CustOrder_seq.nextval into l_CustOrderID from dual;
This statement inserts the new CustOrderID into the header:
Code:
insert into CustOrder (CustOrderID, OrderDate, CustID, DateComplete, OrderTotal)
                values(l_CustOrderID, sysdate, l_CustID, NULL, NULL);
This last statement inserts the new CustOrderID into the OrderLine table:
Code:
  insert into OrderLine 
      (OrderLineID, CustOrderID, SKU, LineQty, UnitPrice)
      values (NULL, l_CustOrderID, x.c001, x.c004, x.c003);
What I don't understand is if I have created the new CustOrderID using the sequence and then doing the inserts, why do I continue to get this error?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 01-05-12, 09:54
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On