First, there is a table:
CREATE TABLE T_salary ( name VARCHAR2, age number (2), SALARY number (5)), insert into t_salary (name, age, SALARY) VALUES (' Wyl ', Th, 63000), insert into t_salary (name, age, SALARY) VALUES (' Werxiao ', +, 6012); Insert I Nto t_salary (name, age, salary) VALUES (' Lisi ', si, 7000), insert into t_salary (name, age, salary) VALUES (' Zhangsan ', 42, 4521);
Trigger Scenario 1: Complex security checks, as follows
CREATE OR REPLACE TRIGGER t_security_t_salarybefore updateon t_salary/* trigger Scenario 1: Complex security checks prohibit operating tables during non-working hours Weekends or not between 9 and 18 points, for non-working time */begin IF (To_char (sysdate, ' Day ') in (' Saturday ', ' Sunday ')) or To_number (To_char (Sysdate, ' Hh24 ')) not between 9 and then--to_number (To_char (sysdate, ' hh24 ')) between 9 and then --Prohibit insert new employee
raise_application_error ('-20002 ', ' non-working hours not allowed to operate this table '); END IF; END;
Where the first parameter of Raise_application_error () is between 20999 and-20000. As follows:
Trigger Application Trigger