create or replace triggertrg_x_yonghu_log_aft_modify
afterupdate OF shouji, zigezhenghao,zidianshurufa,shurufa onx_yonghuforeach rowdeclarepri_sqlcodevarchar2(100);
pri_sqlerrmvarchar2(4000);
pri_usernamevarchar2(50);
pri_ipvarchar2(100);
pri_hostvarchar2(200);
pri_typevarchar2(100);beginpri_username := sys_context('userenv', 'session_user');
pri_ip := sys_context('userenv', 'ip_address');
pri_host := sys_context('userenv', 'host');
pri_type := 'update';case when updating('shouji') or updating('zidianshurufa') or updating('shurufa') then
if :new.shouji != :old.shouji or :new.zidianshurufa != :old.zidianshurufa or :new.shurufa != :old.shurufa then
insert intox_yonghu_log
(yonghuid_old,
yiyuanid_old,
zidianshurufa_old,
shurufa_old,
shouji_old,
zigezhenghao_old,
yonghuid_new,
yiyuanid_new,
zidianshurufa_new,
shurufa_new,
shouji_new,
zigezhenghao_new,
modify_host,
modify_ip,
modify_username,
modify_type)values(:old.yonghuid,
:old.yiyuanid,
:old.zidianshurufa,
:old.shurufa,
:old.shouji,
:old.zigezhenghao,
:new.yonghuid,
:new.yiyuanid,
:new.zidianshurufa,
:new.shurufa,
:new.shouji,
:new.zigezhenghao,
pri_host,
pri_ip,
pri_username,
pri_type);end if;end case;
exceptionwhen others then
beginpri_sqlcode :=sqlcode;
pri_sqlerrm :=sqlerrm;insert intox_yonghu_log
(modify_username,
modify_ip,
modify_host,
modify_type,
errormsg_sqlcode,
errormsg_sqlerrm)values(pri_username,
pri_ip,
pri_host,
pri_type,
pri_sqlcode,
pri_sqlerrm);end;end;