我是靠谱客的博主 落后八宝粥,这篇文章主要介绍oracle 触发器中if,oracle触发器--if else demo,现在分享给大家,希望可以做个参考。

CREATE OR REPLACE Trigger trig_solr_index_el_lesson

After Update of lessonid, lessonname, lessongoal, note, teachername, teacherid, classidname, classid, crtime, status Or Delete or insert On el_lesson

For Each Row

declare

-- local variables here

new_status number;

begin

new_status := :NEW.status;

if inserting then

begin

INSERT INTO solr_index

(id, docid, type)

VALUES

(solr_index_seq.NEXTVAL, :NEW.lessonid, 'add');

end;

end if;

if updating then

--对比老的状态和新的状态

if new_status = -1 and :OLD.status != -1 then

INSERT INTO solr_index

(id, docid, type)

VALUES

(solr_index_seq.NEXTVAL, :OLD.lessonid, 'delete');

else

INSERT INTO solr_index

(id, docid, type)

VALUES

(solr_index_seq.NEXTVAL, :OLD.lessonid, 'update');

end if;

end if;

if deleting then

begin

INSERT INTO solr_index

(id, docid, type)

VALUES

(solr_index_seq.NEXTVAL, :OLD.lessonid, 'delete');

end;

end if;

end;

最后

以上就是落后八宝粥最近收集整理的关于oracle 触发器中if,oracle触发器--if else demo的全部内容,更多相关oracle内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部