Results 1 to 4 of 4

Thread: triggers

  1. #1
    Join Date
    Apr 2004
    Posts
    7

    Question Unanswered: triggers

    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.

  2. #2
    Join Date
    Mar 2004
    Location
    Venice,Italy
    Posts
    20
    try this:

    create or replace trigger ins_booking after insert on booking
    begin
    update car
    set car_availability='NO'
    where car_id in (select car_id from :NEW);
    END;

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I'm afraid your trigger won't compile, Zeus ...

    But this one will
    PHP Code:
    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

  4. #4
    Join Date
    Apr 2004
    Posts
    7

    trigger not running properly

    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

Posting Permissions

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