CREATE [or REPLACE] TRIGGER 触发器名
{BEFORE | AFTER}
{DELETE | INSERT | UPDATE [OF列名]}
ON 表名
[FOR EACH ROW [WHEN(条件) ] ]
PLSQL 块
限制非工作时间向数据库插入数据
create or replace
trigger insertEmp
before insert on emp
declare
begin
if to_char(sysdate,'day') in ('星期六') or to_number(to_char(sysdate,'hh24')) between 18 and 24
then
raise_application_error(-20001,'非工作日');
end if;
end;
确认数据(检查emp表中sal的修改值不低于原值)
create or replace trigger updateemp
before update on emp
for each row
declare
-- local variables here
begin
if:new.sal<:old.sal then
raise_application_error(-20001,'更改的值不能小于眼有的值');
end if;
end updateemp;