触发器,就是触发一件事情的发生,可能在事前,事后,或者进行中
CREATE OR REPLACE TRIGGER AOLDEMO.trigger1
AFTER DELETE OR INSERT OR UPDATE
ON AOLDEMO.S_EMP
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
tmpVar NUMBER;
/******************************************************************************
   NAME:       trigger1
   PURPOSE:       REVISIONS:
   Ver        Date        Author           Description
   ---------  ----------  ---------------  ------------------------------------
   1.0        2005-10-10             1. Created this trigger.   NOTES:   Automatically available Auto Replace Keywords:
      Object Name:     trigger1
      Sysdate:         2005-10-10
      Date and Time:   2005-10-10, 15:38:14, and 2005-10-10 15:38:14
      Username:         (set in TOAD Options, Proc Templates)
      Table Name:      S_EMP (set in the "New PL/SQL Object" dialog)
      Trigger Options:  (set in the "New PL/SQL Object" dialog)
******************************************************************************/
BEGIN
   tmpVar := 0;   SELECT MySeq.NEXTVAL INTO tmpVar FROM dual;
   :NEW.SequenceColumn := tmpVar;
   :NEW.CreatedDate := SYSDATE;
   :NEW.CreatedUser := USER;   EXCEPTION
     WHEN OTHERS THEN
       -- Consider logging the error and then re-raise
       RAISE;
END trigger1;