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
FOR EACH ROW
SET car_availability = 'NO'
WHERE car_id = :NEW.car_id;
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
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.