Question:
I did not find a SQL IF
statenment in SQLite and the closest one was CASE
, which is serving me, however I would like to suspend a trigger through a conditional and I believe it can only be done with IF
CREATE TRIGGER...
BEGIN
IF (SELECT COUNT(*) FROM DATA < 900) THEN
SUSPEND;
...
END;
Is it possible to do something like this in SQLite?
Answer:
CREATE TRIGGER ...
AFTER UPDATE ON table WHEN NEW.field = 1
BEGIN
...
END
It can also be done with more than one conditional:
CREATE TRIGGER ...
AFTER UPDATE ON table WHEN NEW.field = 1 AND (SELECT COUNT(*) FROM table) >= 900
BEGIN
...
END