Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    7

    Unanswered: ORA-02291: integrity constraint () violated -parent key found

    I have 2 tables BOOKING (booking_id, car_id) and CAR (car_id, car_availability). the field car_availability takes the value YES/NO. I want to create a trigger so that whenever I make an entry in the BOOKING table for the car that is rented, that car_id 's availability field in the CAR table should be set to NO. The trigger I have created is as follows

    CREATE OR REPLACE TRIGGER trg_a_i_booking
    AFTER INSERT
    ON booking
    FOR EACH ROW
    BEGIN
    UPDATE car
    SET car_availability = 'NO'
    WHERE car_id = :NEW.car_id;
    END;

    this trigger has been created successfully but it is not doing what i want it to do. when inserting into the booking table, it is giving an error saying :

    ORA-02291: integrity constraint () violated -parent key found

    how should i proceed????
    pls help

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: ORA-02291: integrity constraint () violated -parent key found

    Actually it says this:

    ORA-02291: integrity constraint (<constraint name>) violated - parent key not found

    It almost certainly has nothing to do with your trigger, it means that in your insert statement you specified a foreign key value in the BOOKING table that does not correspond to any value in the table that is referenced by that foreign key. The name of the constraint is given in the error message.

Posting Permissions

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