Oracle SQL Commands: Part 2
Create trigger Command
參考文章:http://www.c-sharpcorner.com/UploadFile/nipuntomar/sql-commands-part-2/
作者有提供範例:頗方便,可以直接應用。
CREATEOR REPLACETRIGGER Product_before_insert
BEFORE INSERT
ON Products
FOR EACH ROW
DECLARE
username varchar2(15);
BEGIN
-- Find username of person performing INSERT into table
SELECTuser INTO username
FROM dual;
-- Update create_date field to current system date
:new.create_date:= systemdate;
-- Update created_by field to the username of the person performing the INSERT
:new.created_by:= username;
END;
全站熱搜