Results 1 to 8 of 8
  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;

    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
    Jan 2004
    Location
    India
    Posts
    191
    Table Car (car_id, car_availability). The column car_availability is referencing(foreign key) column and u are updating same column ..which is voilating integrety constarint while updation

    Thanks,
    Pagnint
    (No need to search web before posting new question)

  3. #3
    Join Date
    Mar 2004
    Location
    California
    Posts
    58
    Are you saying that car_availibility is a foreign key? Cuz it doesnt seem like it...is this true?

    Originally posted by paginit
    Table Car (car_id, car_availability). The column car_availability is referencing(foreign key) column and u are updating same column ..which is voilating integrety constarint while updation

    Thanks,

  4. #4
    Join Date
    Jan 2004
    Location
    India
    Posts
    191
    Yes, i think the car_availabity is the foreign key?

    Thanks,
    Pagnint
    (No need to search web before posting new question)

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Fahad,

    would you mind posting scripts that create those tables?

  6. #6
    Join Date
    Jan 2004
    Location
    Singapore
    Posts
    89
    Originally posted by Littlefoot
    Fahad,

    would you mind posting scripts that create those tables?
    I think the problem is not because of these table, there is some cascading happening in some other table, we will have to see other triggers on the table booking.
    Thanks and Regards,

    Praveen Pulikunnu

  7. #7
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    This is initial Fahad's post about the subject (in SQL forum):
    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 in oracle so that whenever I make an entry in the BOOKING table for car_id, that same car_id 's availability in the CAR table should be set to NO.
    While discussing the problem, I created those tables without primary / foreign keys and inserts into BOOKING triggered update in CAR table without errors.
    That's why I guessed it must be something about the code Fahad used to create those tables.
    Of course, there may be another table(s) involved, and I must agree with you, Praveenpr ... we lack in data to give an answer to this

  8. #8
    Join Date
    Apr 2004
    Posts
    7

    trigger working properly

    thank you everyone for all ur help,
    trigger is now full functional,
    it couldn't have been without ur help
    thanx

Posting Permissions

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