只能在工作时间内更新某表

例如规定只能在工作时间内更新Student表,可以定义如下触发器,其中sysdate为系统当前时间

CREATE OR REPLACE TRIGGER secure_student
   BEFORE INSERT OR UPDATE OR DELETE
   ON student
BEGIN
   IF    (TO_CHAR (SYSDATE, 'DY') IN ('SAT', 'SUN'))
      OR (TO_NUMBER (SYSDATE, 'HH24') NOT BETWEEN 8 AND 17)
   THEN
      raise_application_error
                    (-20506,
                     'You may only change data during normal business hours.'
                    );
   END IF;
END;

猜你喜欢

转载自www.cnblogs.com/oracle-ziyuhou/p/10505260.html