qq_34708274 2017-11-03 05:49 采纳率: 0%
浏览 2589
已结题

oracle触发器:为什么update可以触发,但是insert就不行啊!大神们快围观啊!!!!!!

CREATE OR REPLACE TRIGGER b2b_person_tri
AFTER INSERT OR UPDATE ON SYS_PERSON
FOR EACH ROW

DECLARE
v_entryid NUMBER(10);
v_personinfoid number(10);
PRAGMA AUTONOMOUS_TRANSACTION;

BEGIN
CASE
WHEN INSERTING THEN
select count(*) into v_entryid from sys_person p,b2b_entryconf t
where p.entryid = t.entryid
and p.personid = :new.personid;

if v_entryid > 0 then
select sys_nextid_fun('EDIS_UNTINTF_SEQ') into v_personinfoid from dual;
insert into edis_untintf(
edis_untintf_seq,
edis_untintf_sourceid,
edis_untintf_comefrom,
edis_untintf_intfname,
edis_untintf_credate,
edis_untintf_modol
)
values(
v_personinfoid,
:new.personid,
'SYS_PERSON',
'B2B',
sysdate,
'insert'
);
end if;
WHEN updating THEN
select count(*) into v_entryid from sys_person p, b2b_entryconf t
where p.entryid = t.entryid
and p.personid = :old.personid;

         if v_entryid > 0 then
            select sys_nextid_fun('EDIS_UNTINTF_SEQ') into v_personinfoid from dual;
            insert into edis_untintf(
                   edis_untintf_seq,
                   edis_untintf_sourceid,
                   edis_untintf_comefrom,
                   edis_untintf_intfname,
                   edis_untintf_credate,
                   edis_untintf_modol
            )
            values(
                   v_personinfoid,
                   :old.personid,
                   'SYS_PERSON',
                   'B2B',
                   sysdate,
                   'update'
            );
            commit;
       end if;

END CASE;

END;

  • 写回答

3条回答

  • meicuojiushiwoi 2017-11-03 07:38
    关注

    不大懂你写的啥,不过好像如果模式都一样的话你在insert下面好像没有提交

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算