Oracle如何使用触发器实现第三者识别码SEQID的变更?

默认分类 未结 1 1304
_Nanjolno_
_Nanjolno_ 2023-03-18 05:43
相关标签:
1条回答
  • 2023-03-18 05:49

    根据你的描述,建议你用存储过程来实现,而不是触发器。触发器操作本表会有变异表的错误。存储过程的大概写法如下:create or replace procere insert_DS_THIRDACCIDENTINFO(入参)as ncount number;begin select count(*) into ncount from DS_THIRDACCIDENTINFO where ACCID=入参的事故流水号 if ncount >0 then 插入SEQID=0 的数据 else 插入SEQID=1 的数据 end if;end;删除也类似实现就好了!

    create or replace trigger Itbefore insert on DS_THIRDACCIDENTINFO for each rowdeclare ncount Number; begin select count(*) into n_count from DS_THIRDACCIDENTINFO where accid=:New.accid and seqid = 1; If ncount>0 then :New.seqid := 0; else :New.seqid := 1; end if; end;

    问题描述的不够清楚,你这表结构弄的真够乱的

    0 讨论(0)
提交回复