Connecting Tech Pros Worldwide Forums | Help | Site Map

Trigger Before Insert or Update

Newbie
 
Join Date: Apr 2009
Posts: 1
#1: Apr 15 '09
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.vpreparedby := NVL (:new.vpreparedby, USER);
:new.dentrydate := NVL (:new.dentrydate, SYSDATE);
ELSE
:new.vmaintainedby := NVL (:new.vmaintainedby, USER);
:new.dmaintaineddate := NVL (:new.dmaintaineddate, SYSDATE);
END IF;
END;

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Apr 24 '09

re: Trigger Before Insert or Update


Here, read this


--- CK
Reply

Tags
insert, sql, trigger, update


Similar Microsoft SQL Server bytes