例如規定只能在工做時間內更新Student表,能夠定義以下觸發器,其中sysdate爲系統當前時間app
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;spa