--触发器
/*
insert
delete
update

类型:两种
一种叫行级触发器
表级触发器

update t_student s set s.sname='1111' where s.sno=11111
*/
CREATE OR REPLACE TRIGGER tg_test
AFTER INSERT
ON t_student
BEGIN
dbms_output.put_line('插入了一条数据 !');
END;


CREATE OR REPLACE TRIGGER tg_test_row
AFTER UPDATE
ON t_student
BEGIN
dbms_output.put_line('插入了一条数据 !');
END;
/*
to_char(sysdate, 'day') not in ('星期六','星期日')
to_char(SYSDATE, 'hh24') between 10 and 17
*/
CREATE OR REPLACE TRIGGER checkforinsert
BEFORE INSERT
ON t_student

BEGIN
IF NOT (to_char(sysdate, 'day') not in ('星期六','星期日') AND to_char(SYSDATE, 'hh24') between 10 and 17) THEN
raise_application_error(-20001, '非工作时间不能添加数据 !');
END IF
END;