概述
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 触发器中if,oracle触发器--if else demo所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复