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

The WHEN clause is an attempt to avoid infinite recursion that UPDATE
within an UPDATE would cause. However I get SQL errors when I try defining
a trigger this way this in my favorite db dbrowser.

Maybe using triggers for this is flawed, and I should just ensure all
update statements set the column, or am I missing a trick?
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to