SQLite Forum

create trigger
Login
I want to create two triggers, one for insert and one for update, that set a column to the current datetime.
I have "found" these on the net and they seems to work but I need to ask about the WHERE part of the SQL.

~~~~~
 CREATE TRIGGER insert_process_order AFTER INSERT ON ProcessingOrders
 BEGIN
  UPDATE ProcessingOrders SET Created = DATETIME('NOW', 'localtime') WHERE ROWID = new.ROWID;
 END;
~~~~~

and

~~~~~
 CREATE TRIGGER update_process_order AFTER UPDATE ON ProcessingOrders
 BEGIN
   UPDATE ProcessingOrders SET Modified= DATETIME('NOW', 'localtime') WHERE ROWID = new.ROWID;
 END;
~~~~~

Why is the **WHERE** part needed?
Isn't the trigger called for the row that has been inserted or updated?
Also if the triggers are totally wrong please advise on how to make them 
better.

// Anders
(Edit by drh: fixed formatting)