I need Help for error ORA-02291

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nouralai1
    New Member
    • Jun 2013
    • 1

    #1

    I need Help for error ORA-02291

    Code:
    ALTER TABLE LEASE_2 
        ADD CONSTRAINT CLIENT_LEASE FOREIGN KEY 
        ( 
         CLIENT_ID1
        ) 
        REFERENCES CLIENT_2 
        ( 
         CLIENT_ID
        ) 
        ON DELETE CASCADE
    Error starting at line 244 in command:
    Insert into STUDENT.LEASE_2 (LEASE_ID,MONTH LY_RENT,PAYMENT _TYPE,DURATION_ OF_LEASE,LEASE_ START_DATE,LEAS E_END_DATE,PROP ERTY_ID,CLIENT_ ID1) values
    (1,130000,'CASH ','TWO YEARS',to_date( '13-SEP-12','DD-MON-RR'),to_date('1 3-SEP-14','DD-MON-RR'),1,123)


    Error starting at line 245 in command:
    Insert into STUDENT.LEASE_2 (LEASE_ID,MONTH LY_RENT,PAYMENT _TYPE,DURATION_ OF_LEASE,LEASE_ START_DATE,LEAS E_END_DATE,PROP ERTY_ID,CLIENT_ ID1) values
    (1,130000,'CASH ','TWO YEARS',to_date( '13-SEP-12','DD-MON-RR'),to_date('1 3-SEP-14','DD-MON-RR'),1,123)


    Error report:
    SQL Error: ORA-02291: integrity constraint (STUDENT.LEASE_ RENT) 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.
    Last edited by Rabbit; Jun 5 '13, 03:31 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.


    It's a fairly clear error message. It's saying that your foreign keys have no matching primary key in the contraint that you are creating. The error message even tells you how to fix it: Delete the foreign key or add a matching primary key.
    Last edited by Rabbit; Jun 5 '13, 05:04 PM.

    Comment

    Working...