1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

3 connections, tab, insert

Discussion in 'General' started by monkey, Apr 20, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Dear All!
    I have 3 connections on the same computor to oracle sql deeloper.
    Have 6 tables.

    Day before i had no errors,
    before it-and now again- i got next errors:
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.

    Error starting at line 24 in command:
    INSERT INTO LECTURE VALUES('L1','PIANNO',10)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 25 in command:
    INSERT INTO LECTURE VALUES('L2','VIOLA',20)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 26 in command:
    INSERT INTO LECTURE VALUES('L3','BMW',30)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 27 in command:
    INSERT INTO LECTURE VALUES('L4','AUDI',40)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 28 in command:
    INSERT INTO LECTURE VALUES('L5','DOGS',10)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 29 in command:
    INSERT INTO LECTURE VALUES('L6','CATS',20)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 30 in command:
    INSERT INTO LECTURE VALUES('L7','PIANNO',30)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 31 in command:
    INSERT INTO LECTURE VALUES('L8','VIOLA',40)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 32 in command:
    INSERT INTO LECTURE VALUES('L9','BMW',10)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 33 in command:
    INSERT INTO LECTURE VALUES('L10','AUDI',20)
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LECTURE_PPRICE) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.
    1 rows inserted.

    Error starting at line 57 in command:
    INSERT INTO LP VALUES('LP1', 'L1', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 58 in command:
    INSERT INTO LP VALUES('LP2', 'L2', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 59 in command:
    INSERT INTO LP VALUES('LP3', 'L3', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 60 in command:
    INSERT INTO LP VALUES('LP4', 'L4', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 61 in command:
    INSERT INTO LP VALUES('LP5', 'L5', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 62 in command:
    INSERT INTO LP VALUES('LP6', 'L6', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 63 in command:
    INSERT INTO LP VALUES('LP7', 'L7', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 64 in command:
    INSERT INTO LP VALUES('LP8', 'L8', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 65 in command:
    INSERT INTO LP VALUES('LP9', 'L9', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 66 in command:
    INSERT INTO LP VALUES('LP10','L10', 'Ana')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 67 in command:
    INSERT INTO LP VALUES('LP11','L1', 'Maja')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    Error starting at line 68 in command:
    INSERT INTO LP VALUES('LP12','L2', 'Maja')
    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT330.FK_LP_LNAME) violated - parent key not found
    02291. 00000 - "integrity constraint (%s.%s) violated - parent key not found"
    *Cause: A foreign key value has no matching primary key value.
    *Action: Delete the foreign key or add a matching primary key.

    insert file is (the same as it was when everythign was ok)
    INSERT INTO COURSE VALUES('MUSIC');
    INSERT INTO COURSE VALUES('CARS');
    INSERT INTO COURSE VALUES('ANIMALS');


    REM CREATE TABLE COURSE(
    REM CNAME VARCHAR2(10) NOT NULL
    REM );



    INSERT INTO TOPIC VALUES('PIANNO','MUSIC');
    INSERT INTO TOPIC VALUES('VIOLA','MUSIC');
    INSERT INTO TOPIC VALUES('BMW','CARS');
    INSERT INTO TOPIC VALUES('AUDI','CARS');
    INSERT INTO TOPIC VALUES('DOGS','ANIMALS');
    INSERT INTO TOPIC VALUES('CATS','ANIMALS');

    REM CREATE TABLE TOPIC(
    REM TNAME VARCHAR2(10) NOT NULL ,
    REM FK_CNAME VARCHAR2(10) NOT NULL
    REM );

    INSERT INTO LECTURE VALUES('L1','PIANNO',10);
    INSERT INTO LECTURE VALUES('L2','VIOLA',20);
    INSERT INTO LECTURE VALUES('L3','BMW',30);
    INSERT INTO LECTURE VALUES('L4','AUDI',40);
    INSERT INTO LECTURE VALUES('L5','DOGS',10);
    INSERT INTO LECTURE VALUES('L6','CATS',20);
    INSERT INTO LECTURE VALUES('L7','PIANNO',30);
    INSERT INTO LECTURE VALUES('L8','VIOLA',40);
    INSERT INTO LECTURE VALUES('L9','BMW',10);
    INSERT INTO LECTURE VALUES('L10','AUDI',20);

    REM CREATE TABLE LECTURE(
    REM LNAME VARCHAR2(10) NOT NULL,
    REM FK_TNAME VARCHAR(10) NOT NULL,
    REM FK_PPRICE INTEGER NOT NULL
    REM );

    INSERT INTO PRICE VALUES(10);
    INSERT INTO PRICE VALUES(20);
    INSERT INTO PRICE VALUES(30);
    INSERT INTO PRICE VALUES(40);

    REM CREATE TABLE PRICE(
    REM PPRICE INTEGER NOT NULL
    REM );

    INSERT INTO PUPIL VALUES('Ana');
    INSERT INTO PUPIL VALUES('Maja');
    REM CREATE TABLE PUPIL(
    REM PNAME VARCHAR2(10) NOT NULL
    REM );


    INSERT INTO LP VALUES('LP1', 'L1', 'Ana');
    INSERT INTO LP VALUES('LP2', 'L2', 'Ana');
    INSERT INTO LP VALUES('LP3', 'L3', 'Ana');
    INSERT INTO LP VALUES('LP4', 'L4', 'Ana');
    INSERT INTO LP VALUES('LP5', 'L5', 'Ana');
    INSERT INTO LP VALUES('LP6', 'L6', 'Ana');
    INSERT INTO LP VALUES('LP7', 'L7', 'Ana');
    INSERT INTO LP VALUES('LP8', 'L8', 'Ana');
    INSERT INTO LP VALUES('LP9', 'L9', 'Ana');
    INSERT INTO LP VALUES('LP10','L10', 'Ana');
    INSERT INTO LP VALUES('LP11','L1', 'Maja');
    INSERT INTO LP VALUES('LP12','L2', 'Maja');

    REM CREATE TABLE LP(
    REM LPNAME VARCHAR2(10) NOT NULL,
    REM FK_LNAME VARCHAR2(10) NOT NULL,
    REM FK_PNAME VARCHAR2(10) NOT NULL
    REM );







    and tab file:

    CREATE TABLE COURSE(
    CNAME VARCHAR2(10) NOT NULL
    );
    ALTER TABLE COURSE
    ADD (CONSTRAINT PK_COURSE PRIMARY KEY (CNAME));






    CREATE TABLE TOPIC(
    TNAME VARCHAR2(10) NOT NULL ,
    FK_CNAME VARCHAR2(10) NOT NULL
    );
    ALTER TABLE TOPIC
    ADD (CONSTRAINT PK_TOPIC PRIMARY KEY (TNAME));

    ALTER TABLE TOPIC
    ADD (CONSTRAINT FK_TOPIC_CNAME FOREIGN KEY
    (FK_CNAME) REFERENCES COURSE(CNAME));





    CREATE TABLE PRICE(
    PPRICE INTEGER NOT NULL
    );
    ALTER TABLE PRICE
    ADD (CONSTRAINT PK_PRICE PRIMARY KEY (PPRICE));




    CREATE TABLE LECTURE(
    LNAME VARCHAR2(10) NOT NULL,
    FK_TNAME VARCHAR(10) NOT NULL,
    FK_PPRICE INTEGER NOT NULL
    );
    ALTER TABLE LECTURE
    ADD (CONSTRAINT PK_LECTURE PRIMARY KEY (LNAME));

    ALTER TABLE LECTURE
    ADD (CONSTRAINT FK_LECTURE_TNAME FOREIGN KEY
    (FK_TNAME) REFERENCES TOPIC(TNAME));

    ALTER TABLE LECTURE
    ADD (CONSTRAINT FK_LECTURE_PPRICE FOREIGN KEY
    (FK_PPRICE) REFERENCES PRICE(PPRICE));





    CREATE TABLE PUPIL(
    PNAME VARCHAR2(10) NOT NULL
    );
    ALTER TABLE PUPIL
    ADD (CONSTRAINT PK_PUPIL PRIMARY KEY (PNAME));





    CREATE TABLE LP(
    LPNAME VARCHAR2(10) NOT NULL,
    FK_LNAME VARCHAR2(10) NOT NULL,
    FK_PNAME VARCHAR2(10) NOT NULL
    );





    ALTER TABLE LP
    ADD (CONSTRAINT PK_LP PRIMARY KEY (LPNAME));

    ALTER TABLE LP
    ADD (CONSTRAINT FK_LP_LNAME FOREIGN KEY
    (FK_LNAME) REFERENCES LECTURE(LNAME));

    ALTER TABLE LP
    ADD (CONSTRAINT FK_LP_PNAME FOREIGN KEY
    (FK_PNAME) REFERENCES PUPIL(PNAME));

    Please, what might be the reason of mistake?
    (p.s I was dropping all, do nto worrry, but the error comes again!)

    Many thanks- PLEASE HELP!
     
  2. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    First of all. You really need to do your own schoolwork.

    The first constraint being violated is FK_LECTURE_PPRICE. From the code creating the constraint, that foreign references the PPRICE column in the PRICE table:

    Code (Text):
    ALTER TABLE LECTURE
    ADD (CONSTRAINT FK_LECTURE_PPRICE FOREIGN KEY
    (FK_PPRICE) REFERENCES PRICE(PPRICE));
    This means that when rows are inserted into LECTURE, they *expect* the PPRICE value to already exist in the PRICE table. However, you have the PRICE table INSERTs after the LECTURE table INSERTs in your script.

    The second constraint being violated is the FK_LP_LNAME foreign key. Use the above logic to find it on your own.