Ha, my error - missing ";" in the UPDATE clause but I was blind. On Thu, 12 Mar 2020 at 08:18, David Blake <[email protected]> wrote:
> Thanks for such a swift reply, good to know that it should work (without > typos) > > >Thank you very much for keeping the error message secret. > > near "END": syntax error: > > > I'm testing out ideas using DB Browser, but will try in my app and see if > this is just a DB Browser issue > > On Thu, 12 Mar 2020 at 08:04, Clemens Ladisch <[email protected]> wrote: > >> David Blake wrote: >> > CREATE TRIGGER my_update_trigger BEFORE UPDATE ON My_table >> > FOR EACH ROW WHEN NEW.lastupdated < OLD. lastupdated >> > BEGIN >> > UPDATE my_tableSET 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. >> >> Typical UPDATE statements will leave this field with its old value, so >> it might be a better ideas to use <= instead of <. >> >> > However I get SQL errors when I try defining a trigger this way this >> > in my favorite db dbrowser. >> >> Thank you very much for keeping the error message secret. >> >> When I fix the wrong table table name and add the missing semicolon after >> the UPDATE statement, this trigger works fine. >> >> >> Regards, >> Clemens >> _______________________________________________ >> sqlite-users mailing list >> [email protected] >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> > _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

