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 DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP
But the "on update" part does not work with SQLite.
I could not find a way to do it automatically, do I need to declare a trigger?
EDIT: For the record, here is my current trigger:
CREATE TRIGGER [UpdateLastTime]
AFTER UPDATE
ON Package
FOR EACH ROW
BEGIN
UPDATE Package SET LastUpdate = CURRENT_TIMESTAMP WHERE ActionId = old.ActionId;
END
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…