On 12/03/2020 08:47, David Blake wrote:
I'm looking for an easy way to maintain a last updated column for each record in several tables and considering if using a triggers is viable.I thought that defining a trigger like this on each table would work CREATE TRIGGER my_update_trigger BEFORE UPDATE ON My_table FOR EACH ROW WHEN NEW.lastupdated < OLD. lastupdated BEGIN UPDATE song SET lastupdated = DATETIME('now') WHERE id = NEW.id END
As far as I know, updating the current row in a "before" trigger is a "nop" in SQLite since this row does not exist yet (for my information, could you check?). However, this works fine in an "after" trigger.
In addition, the role of the "when" clause is unclear. Is it necessary? JLH -- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

