create or replace trigger tri_prent before INSERT or update or delete ON yxgl_kcgl FOR EACH ROWdeclare begin if :new.szdw not in ('500171','500172','500173','500174','500175','500176','500177','500178','500179','500180','500181','300005') then raise_application_error(-20000,'不能操作数据!'); end if; end tri_prent;
CREATE OR REPLACE TRIGGER JXXLUSER.MYTRIGGER ----触发器名 AFTER INSERT ----插入后触发 ON JXXLUSER.JOBTEST -----在此表上触发 FOR EACH ROW DECLARE BEGIN INSERT INTO TEST1 VALUES(4,5); ---- EXCEPTION WHEN OTHERS THEN -- Consider logging the error and then re-raise RAISE; END ;
create or replace trigger tri_super_user before insert,delete on users for each row as declare v_user varchar2(30):=new.username; begin if v_user='superuser' then raise_application_error(-18752,'superuser couldnot allow insert new or delete it'); return; end if; end tri_super_user; /
create or replace trigger tri_prent
before INSERT or update or delete ON yxgl_kcgl
FOR EACH ROWdeclare
begin
if :new.szdw not in ('500171','500172','500173','500174','500175','500176','500177','500178','500179','500180','500181','300005') then raise_application_error(-20000,'不能操作数据!'); end if;
end tri_prent;
AFTER INSERT ----插入后触发
ON JXXLUSER.JOBTEST -----在此表上触发
FOR EACH ROW
DECLARE
BEGIN
INSERT INTO TEST1 VALUES(4,5); ----
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END ;
要是插入、更新和删除都将会是没问题的,用BEFORE和AFTER来禁止操作,
只能用抛出异常吗???
before insert,delete
on users
for each row
as
declare
v_user varchar2(30):=new.username;
begin
if v_user='superuser' then
raise_application_error(-18752,'superuser couldnot allow insert new or delete it');
return;
end if;
end tri_super_user;
/