一个字数统计的触发器,章节字数增删改时触发卷字数增删改(卷字数增删改时触发书字数增删改同理):
trigger5 触发AFTER 插入
begin
update wor_volume
set VolumeWordCount=(SELECT sum(ContentWordCount)
FROM wor_content WHERE wor_content.VolumeId =new.VolumeId )
where VolumeId =new.VolumeId ;
end
trigger6 触发AFTER 更新
begin
update wor_volume
set VolumeWordCount=(SELECT sum(ContentWordCount)
FROM wor_content WHERE wor_content.VolumeId =new.VolumeId )
where VolumeId =new.VolumeId ;
end
trigger7 触发AFTER 删除
begin
update wor_volume
set VolumeWordCount=(SELECT sum(ContentWordCount)
FROM wor_content WHERE wor_content.VolumeId =old.VolumeId )
where VolumeId =old.VolumeId ;
end