I want to update a field with the current timestamp whenever the row is updated.
In MySQL I would do, when declaring the table
LastUpdate TIMESTAMP D
John is correct about the default SQLite settings, this trigger leads to an infinite loop. To avoid recursion, use the WHEN clause.
Following will work even if the recursive_triggers
setting is on:
PRAGMA recursive_triggers=1; --- test
CREATE TRIGGER [UpdateLastTime]
AFTER UPDATE
ON package
FOR EACH ROW
WHEN NEW.LastUpdate < OLD.LastUpdate --- this avoid infinite loop
BEGIN
UPDATE Package SET LastUpdate=CURRENT_TIMESTAMP WHERE ActionId=OLD.ActionId;
END;