create or replace trigger singleFactorMethodtest --after insert or update after insert on hm_v2_test for each row declare cd_standard hm_standard.cd_standard%type; hg_standard hm_standard.hg_standard%type; dp_as_standard hm_standard.dp_as_standard%type; cu_standard hm_standard.cu_standard%type; pb_standard hm_standard.pb_standard%type; cr_standard hm_standard.cr_standard%type; zn_standard hm_standard.zn_standard%type; ni_standard hm_standard.ni_standard%type; begin SELECT cd_standard INTO cd_standard FROM hm_standard; SELECT hg_standard INTO hg_standard FROM hm_standard; SELECT dp_as_standard INTO dp_as_standard FROM hm_standard; SELECT cu_standard INTO cu_standard FROM hm_standard; SELECT pb_standard INTO pb_standard FROM hm_standard; SELECT cr_standard INTO cr_standard FROM hm_standard; SELECT zn_standard INTO zn_standard FROM hm_standard; SELECT ni_standard INTO ni_standard FROM hm_standard; insert into hm_pollution_level values(:new.objectid,:new.cd/cd_standard,:new.hg/hg_standard,:new.dp_as/dp_as_standard,:new.cu/cu_standard,:new.pb/pb_standard,:new.cr/cr_standard,:new.zn/zn_standard,:new.ni/ni_standard); end;
create or replace trigger singleFactorMethod_update --after insert or update after update on hm_v2_test for each row declare cd_standard hm_standard.cd_standard%type; hg_standard hm_standard.hg_standard%type; dp_as_standard hm_standard.dp_as_standard%type; cu_standard hm_standard.cu_standard%type; pb_standard hm_standard.pb_standard%type; cr_standard hm_standard.cr_standard%type; zn_standard hm_standard.zn_standard%type; ni_standard hm_standard.ni_standard%type; begin SELECT cd_standard INTO cd_standard FROM hm_standard; SELECT hg_standard INTO hg_standard FROM hm_standard; SELECT dp_as_standard INTO dp_as_standard FROM hm_standard; SELECT cu_standard INTO cu_standard FROM hm_standard; SELECT pb_standard INTO pb_standard FROM hm_standard; SELECT cr_standard INTO cr_standard FROM hm_standard; SELECT zn_standard INTO zn_standard FROM hm_standard; SELECT ni_standard INTO ni_standard FROM hm_standard; update hm_pollution_level set cd_level=:new.cd/cd_standard,hg_level=:new.hg/hg_standard ,dp_as_level=:new.dp_as/dp_as_standard ,cu_level=:new.cu/cu_standard,pb_level=:new.pb/pb_standard,cr_level=:new.cr/cr_standard ,zn_level=:new.zn/zn_standard ,ni_level=:new.ni/ni_standard where objectid=:new.objectid; end;
create or replace trigger singleFactorMethod_delete --after insert or update after delete on hm_v2 for each row begin delete from hm_pollution_level where objectid=:old.objectid; end;
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1315465