On 10/18/08, Kristofer Hindersson <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> Thank you for answering my question regarding a trigger for updating my
> updated-field. I was just wondering if I should really be using the AFTER
> INSERT ON statement instead of  AFTER UPDATE ON? Wouldn't the first one only
> work if I'm creating a new entry? (Instead of just modifying an already
> existing entry.)
>

You are correct. I did not read your question carefully. The following
should do the trick --

CREATE TRIGGER add_date AFTER UPDATE ON Entries
BEGIN
  UPDATE Entries SET updated = datetime('now') WHERE entryID = old.entryID;
END;

And yes, as Enrique pointed out, keep in mind that all times are UTC
unless explicitly set to your localtime.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to