源:
评:
主表 haier2013_datatoupiao
子表 haier2013_data board_id = 15的为 用户投票内容信息
[img]http://static.oschina.net/uploads/space/2014/0108/140956_Mkuy_78498.png[/img]
create or replace trigger HAIER_TOUPIAO_BOARD_ID_15_17
after insert on haier2013_data
for each row
declare
-- local variables here
lpos1 number :=1;
lpos2 number :=1;
lbuff varchar2(50) :='';
begin
if :new.board_id = 15 then
while lpos1 <= length(:new.remark1) loop
lpos2 :=instr(:new.remark1, ';', lpos1, 1);
if lpos2 = 0 then
lbuff := substr(:new.remark1,lpos1, 1);
update haier2013_datatoupiao t set t.con_type= t.con_type+1 where t.board_id = 17 and t.name = lbuff;
exit;
end if;
lbuff:=substr(:new.remark1, lpos1, 1);
update haier2013_datatoupiao t set t.con_type= t.con_type+1 where t.board_id = 17 and t.name = lbuff;
lpos1 := lpos2 + 1;
end loop;
end if;
end HAIER_TOUPIAO_BOARD_ID_15_17;
评:
主表 haier2013_datatoupiao
子表 haier2013_data board_id = 15的为 用户投票内容信息
[img]http://static.oschina.net/uploads/space/2014/0108/140956_Mkuy_78498.png[/img]
create or replace trigger HAIER_TOUPIAO_BOARD_ID_15_17
after insert on haier2013_data
for each row
declare
-- local variables here
lpos1 number :=1;
lpos2 number :=1;
lbuff varchar2(50) :='';
begin
if :new.board_id = 15 then
while lpos1 <= length(:new.remark1) loop
lpos2 :=instr(:new.remark1, ';', lpos1, 1);
if lpos2 = 0 then
lbuff := substr(:new.remark1,lpos1, 1);
update haier2013_datatoupiao t set t.con_type= t.con_type+1 where t.board_id = 17 and t.name = lbuff;
exit;
end if;
lbuff:=substr(:new.remark1, lpos1, 1);
update haier2013_datatoupiao t set t.con_type= t.con_type+1 where t.board_id = 17 and t.name = lbuff;
lpos1 := lpos2 + 1;
end loop;
end if;
end HAIER_TOUPIAO_BOARD_ID_15_17;
触发器实现投票计数
本文介绍了一个使用Oracle PL/SQL触发器实现的投票计数系统。该触发器在用户投票后更新另一个表中的计数信息,通过解析投票备注中的分号分割的数据来更新对应的记录。
3306

被折叠的 条评论
为什么被折叠?



