Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Unanswered: Oracle SQL Error: ORA-02291: integrity constraint

    I am creating tables in Oracle database SQL developer, I am in the middle of populating the tables with data then selecting it. I have the following CREATE statement for the itemOrdered table

    Code:
    CREATE TABLE ItemOrdered(OrderID varchar2(9) REFERENCES Ords(OrderID), BeltID varchar2(9)
    REFERENCES BeltID(BeltID), 
    Quantity varchar(4) NOT NULL, PRIMARY KEY(OrderID, BeltID))
    As you can see that I have a composite key made up of OrderID and BeltID. Having successfully created this table I am now trying to insert the following row of data

    Code:
    INSERT INTO ItemOrdered VALUES(401565981,234489212,'2')
    When trying to run the following statement i get the following error

    Error report:
    SQL Error: ORA-02291: integrity constraint (Home.SYS_C004411) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"


    I understand that the values have to correspond to the parent tables OrdsID and BeltID. I have also supplied a link of what I have currently done so far.

    SQL | CREATE TABLE Customers(CustomerID varchar2(9) PRIM

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool Who's your daddy?

    And what is it you do not understand about "violated - parent key not found"?

    You think maybe the corresponding Ords(OrderID) does not exist?
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Dec 2010
    Posts
    2
    Quote Originally Posted by LKBrwn_DBA View Post
    And what is it you do not understand about "violated - parent key not found"?

    You think maybe the corresponding Ords(OrderID) does not exist?

    [/QUOTE]It does exist![/QUOTE]

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Quote Originally Posted by junior1 View Post
    It does exist!
    Oracle disagrees with you & I believe Oracle MUCH more than I ever believe noobie.

    using COPY & PASTE post SQL & results that proves (or not) it exists.
    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.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Mar 2007
    Posts
    623
    Quote Originally Posted by junior1 View Post
    It does exist!
    And what are its data types of ORDERID and BELTID in parent tables?

    Just beware, that although both ORDERID and BELTID are declared as VARCHAR2(9), INSERT statement puts there NUMBERs. It would be proper to INSERT strings there ('401565981','234489212'). Although the implicit conversion may work correctly, I would not depend on it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •