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