#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Trigger help - IF UPDATING THEN


    I've created a trigger named customer_archive_tr on the customer table. The trigger saves the current values of all columns of the customer table to the customer_history table before the record is updated or deleted.

    (Here is where I get confused...)

    If the customer table is being updated, my trigger should also populate 'customer.last_update_date' using SYSDATE and 'customer.last_updated_by' with USER.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    I think this is what you need.

    CASE
    WHEN UPDATING THEN BEGIN
    :new.last_update_date := SYSDATE;
    :new.last_updated_by := USER;
    END
    END CASE;

IMN logo majestic logo threadwatch logo seochat tools logo