>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
... > In addition, the role of the "when" clause is unclear. Is it necessary? I don't think it is. I have a very similar trigger which I've been using for several years And it doesn't have the where... CREATE TRIGGER [UpdatePortTime] AFTER UPDATE ON ports FOR EACH ROW BEGIN UPDATE ports SET timeofday = CURRENT_TIMESTAMP WHERE id = NEW.id ; END Andy ********************************************************************** DISCLAIMER: Privileged and/or Confidential information may be contained in this message. If you are not the addressee of this message, you may not copy, use or deliver this message to anyone. In such event, you should destroy the message and kindly notify the sender by reply e-mail. It is understood that opinions or conclusions that do not relate to the official business of the company are neither given nor endorsed by the company. Thank You. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users