请问数据库 触发器 触发insert的语句怎么写啊
2个回答
展开全部
create trigger insert_data after insert on data_table FOR each row
begin
declare topic_id int;
select topic_uuid into topic_id from subtopic_table where subtopic_table.id=new.subtopic_uuid;
UPDATE sub_data_sum set datasum=datasum+1 where sub_data_sum.id=new.subtopic_uuid;
update data_sum set datasum=datasum+1 where data_sum.id=1;
update data_sum set datasum=datasum+1 where data_sum.id=topic_id;
end;
给你看一下我做的触发器吧,begin和end里面是你要做的处理,insert_data触发器名,after insert 意思就是在insert执行之后
begin
declare topic_id int;
select topic_uuid into topic_id from subtopic_table where subtopic_table.id=new.subtopic_uuid;
UPDATE sub_data_sum set datasum=datasum+1 where sub_data_sum.id=new.subtopic_uuid;
update data_sum set datasum=datasum+1 where data_sum.id=1;
update data_sum set datasum=datasum+1 where data_sum.id=topic_id;
end;
给你看一下我做的触发器吧,begin和end里面是你要做的处理,insert_data触发器名,after insert 意思就是在insert执行之后
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询