Trigger Before Insert or Update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JB4375
    New Member
    • Apr 2009
    • 1

    Trigger Before Insert or Update

    I've created an ASP gridview and made it editable. It displays the information that was entered into a SQL table plus a time stamp and the submitter's user ID.

    In the event information is edited on a specific row, I need to overwrite the time stamp, and requestor on that row to show who edited the entry.

    I've found this example of a trigger for oracle but don't know how to modify it to work with SQL.

    CREATE OR REPLACE TRIGGER "TR_SAMPLE"
    BEFORE INSERT OR UPDATE
    ON table
    FOR EACH ROW
    BEGIN
    IF INSERTING
    THEN
    :new.vpreparedb y := NVL (:new.vprepared by, USER);
    :new.dentrydate := NVL (:new.dentrydat e, SYSDATE);
    ELSE
    :new.vmaintaine dby := NVL (:new.vmaintain edby, USER);
    :new.dmaintaine ddate := NVL (:new.dmaintain eddate, SYSDATE);
    END IF;
    END;
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Here, read this


    --- CK

    Comment

    Working...