当条件满足时 触发器做增删改

create or replace trigger trg_tab_sorting_theme_change
before insert or update of PACKAGE_TYPE or delete
on TAB_SORTING_THEME
for each row
declare
-- local variables here
begin
if inserting then

if :new.PACKAGE_TYPE='分拣机方案' then
INSERT INTO tab_sorting_themes T
(T.THEME_NAME,
T.GUID,
T.PACKAGE_TYPE,
T.BL_START,
T.PRINT_STYLE,
T.INSERT_DATE,
T.REGISTER_SITE_CODE,
T.REGISTER_MAN_CODE,
T.PRINT_STYLE_NAME,
T.SERVICE_PROVIDER_CODE,
T.SERVICE_NAME)
VALUES
(:new.THEME_NAME,
:new.GUID,
:new.PACKAGE_TYPE,
:new.BL_START,
:new.PRINT_STYLE,
:new.INSERT_DATE,
:new.REGISTER_SITE_CODE,
:new.REGISTER_MAN_CODE,
:new.PRINT_STYLE_NAME,
:new.SERVICE_PROVIDER_CODE,
:new.SERVICE_NAME);
end if;

elsif updating then
if :new.PACKAGE_TYPE='分拣机方案' then
update tab_sorting_themes a
set a.THEME_NAME = :new.THEME_NAME,
a.PACKAGE_TYPE = :new.PACKAGE_TYPE,
a.PRINT_STYLE = :new.PRINT_STYLE,
a.REGISTER_SITE_CODE = :new.REGISTER_SITE_CODE,
a.REGISTER_MAN_CODE = :new.REGISTER_MAN_CODE,
a.PRINT_STYLE_NAME = :new.PRINT_STYLE_NAME,
a.SERVICE_PROVIDER_CODE = :new.SERVICE_PROVIDER_CODE,
a.SERVICE_NAME = :new.SERVICE_NAME
where a.GUID = :new.GUID;
end if;
else
if :old.PACKAGE_TYPE = '分拣机方案' then
delete tab_sorting_themes a where a.guid = :old.guid;
end if;
end if;
end trg_tab_sorting_theme_change;

posted @ 2018-06-25 19:31  Debugs  阅读(251)  评论(0编辑  收藏  举报