触发器

create or replace trigger SysnRoute
before insert or update on audit_group
for each ROW--行级别
declare
-- local variables here
nCount number := 0;--声明参数
begin
select count(*)
into nCount
from sys_synmonitor t
where t.sys_synmonitor_id = :new.audit_group_id;--给参数赋值

--判断条件

if (:NEW.VAL_AUDITSTATUS = 1 AND :NEW.VAL_PUBLISH = 1 and
:NEW.CODE_TYPE = 2 and nCount = 0) then
INSERT INTO sys_synmonitor
VALUES
(:NEW.AUDIT_GROUP_ID,
:NEW.TXT_DESIG,
'',
:NEW.DATE_LASTMODIFY,
'', --备注
CASE :NEW.CODE_ACTION
WHEN 0 THEN
'I'
WHEN 1 THEN
'M'
WHEN 2 THEN
'D'
END,
:NEW.TXT_IDENTIFY,
:NEW.TXT_IDENTIFY_DESIG);
end if;
end SysnRoute;

【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/houzf/p/11769855.html