Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2012
    Posts
    4

    Unanswered: Trigger HELP!!!!

    Hello, so I need to create a trigger that will update the orderheader table and set order_completed to sysdate when all the orderlines have been fulfilled

    create or replace trigger Orders_complete
    before update of Order_completed on OrderHeader
    for each row
    WHEN
    (orderline.order_fufilled ='Y')
    BEGIN
    INSERT INTO OrderHeader VALUES (Order_completed)
    (:OLD.Order_completed,:NEW.Order_completed=SYSDATE )
    END;
    /

    but it just says that the trigger has been created with compilation errors!!

    thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Check the syntax for creating a trigger. I would think you need to reference the inserted/updated table like:

    Update ordertable
    Set table.attribute = i.attribute
    From inserted i
    Where ordertable.attribute = i.attribute (e.g. i.order_fufilled ='Y')

    Quote Originally Posted by lagnu View Post
    Hello, so I need to create a trigger that will update the orderheader table and set order_completed to sysdate when all the orderlines have been fulfilled

    create or replace trigger Orders_complete
    before update of Order_completed on OrderHeader
    for each row
    WHEN
    (orderline.order_fufilled ='Y')
    BEGIN
    INSERT INTO OrderHeader VALUES (Order_completed)
    (:OLD.Order_completed,:NEW.Order_completed=SYSDATE )
    END;
    /

    but it just says that the trigger has been created with compilation errors!!

    thanks

  3. #3
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Why do you need a trigger?

    Whatever logic is setting the orderline.order_fulfilled to 'Y' should execute the update (insert?) to the header table.
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    The trigger is written in Oracle syntax. The thread may be better off in the Oracle forum.

Posting Permissions

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