Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    10

    Unanswered: integrity constraint

    i am trying to insert data into the table and i keep getting this error.

    ORA-02291: integrity constraint (OPS$C0261087.SYS_C0099440) violated - parent key not found

    i have read the internet and it says about referencing the tables. I am sure i have put everything in correctly.

    here is the first table

    CREATE TABLE PACKAGE
    (Packageid VARCHAR2(5)
    constraint UC_Packageid check(Packageid=upper(Packageid)),
    Version VARCHAR2(2)
    constraint UC2_Version check(Version=upper(Version)),
    CONSTRAINT PK_TAB PRIMARY KEY(Packageid,Version),
    P_title varchar(60) NOT NULL,
    P_Date Date);

    these are the values inside the table

    INSERT INTO Package VALUES
    ('D2987','31','D2 CONTROL','07-MAY-2001');
    INSERT INTO Package VALUES
    ('DAA19','A1','DATASET','11-JAN-2001');
    INSERT INTO Package VALUES
    ('YA679','A2','YASIS','11-APRIL-2000');
    INSERT INTO Package VALUES
    ('KK028','02','KALI KONTROL','12-OCT-2003');
    INSERT INTO Package VALUES
    ('HH118','11','HODGEHEG','11-SEP-2001');
    INSERT INTO Package VALUES
    ('7EH38','1E','HODGEHEG4','11-SEP-2004');


    here is the other table

    CREATE TABLE PACKAGEAPPLICATION
    (PKID VARCHAR2(5),
    VERSION VARCHAR2(2),
    APPNO VARCHAR2(5),
    FOREIGN KEY(APPNO) REFERENCES APPLICATION(ApplicationNo),
    FOREIGN KEY(PKID,APPNO) REFERENCES PACKAGE(Packageid,Version),
    PRIMARY KEY(PKID,VERSION,APPNO));


    here is where the error is generated when i try to insert this data

    INSERT INTO PACKAGEAPPLICATION VALUES
    ('7EH38','1E','YUE72');


    i have gone back and checked that the data is correct and it is. i have no idea where i am going wrong. can anyone help me please?

  2. #2
    Join Date
    Jan 2003
    Location
    Bangalore
    Posts
    44

    Re: integrity constraint

    Hi,

    Check for the table creation script for the second table you are creating, "FOREIGN KEY(PKID,APPNO) REFERENCES PACKAGE(Packageid,Version)" where as APPNO is varchar(5) and VERSION in PACKAGE table is varchar2(2), totally mismatch of foreign key. The first table has varchar2(2) and the second table has varchar2(5) and you trying to insert the string having 5 characters instead of 2.

    rgds,
    Mahesh

Posting Permissions

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