0
我试图编写触发器来使我的故事数据库的字索引无效。然而,我似乎无法弄清楚在索引操作过程中如何停止触发器再次触发。我知道我需要放置一条if语句来停止更新,但我似乎无法弄清楚它应该是什么样子。更新后触发无效缓存
CREATE TRIGGER trMarkStoryForReindex BEFORE UPDATE ON Chapters
FOR EACH ROW BEGIN
-- any update to any chapter invalidates the index for the whole story
-- we could just periodically flush the story index, but this way is
-- better.
SET New.isIndexed = FALSE;
-- delete the index for that story
-- It will get rebuilt in at most 15 minutes
DELETE FROM freq WHERE storyid = NEW.StoryId;
END;
我基本上只想触发器只有在触发器的update语句中没有设置isIndexed时才触发。
我的数据模型看起来像这样:
章
- ID
- isIndexed
- StoryId
频率
- 字
- storyid
有没有'在'Chapters'表StoryId'场。你的意思是:'从freq中删除where storyid = new.id'? – Barranka
@Barranka章节表中有一个StoryId字段。我只是忘记在问题中加入这个问题。 – HSchmale
请问您可以发布一个数据示例或[SQL小提琴](http://sqlfiddle.com)示例? – Barranka