Hi,
There was some recent discussion about timestamp triggers, something I
have been trying to get working on my own. Specifically, I have two
fields, insert_ts and last_upd_ts, which I would like to be the insert
time and last update time, respectively. However, when I try to write
a trigger to populate these fields, only last_upd_ts gets populated.
I have tried two versions of the trigger:
CREATE TRIGGER task_list_1
AFTER INSERT ON task_list
BEGIN
UPDATE task_list
SET insert_ts = datetime('now','localtime'),
last_upd_ts = datetime('now','localtime')
WHERE task_id = NEW.task_id;
END;
and, thinking that update might only be allowed to populate one column
at a time,
CREATE TRIGGER task_list_1
AFTER INSERT ON task_list
BEGIN
UPDATE task_list SET insert_ts = datetime('now','localtime')
WHERE
task_id = NEW.task_id;
UPDATE task_list SET last_upd_ts = datetime('now','localtime')
WHERE
task_id = NEW.task_id;
END;
Do I have to write a seperate trigger for each column that I want to
update? That seems inefficient to me, so hopefully there is another
way.
Thanks for any help,
Bill