Hello,
I stumbled on a problem with triggers that I have condensed into the following
test script:
-- bug.script
CREATE TABLE atable
(cutoff_date CHAR(10), last_update CHAR(10))
;
INSERT INTO atable(cutoff_date, last_update)
VALUES('2013-10-11', '2013-10-11')
;
SELECT * FROM atable;
CREATE TRIGGER atable_updated AFTER UPDATE ON atable
FOR EACH ROW
BEGIN
UPDATE atable SET cutoff_date = date('now', '-6 days');
END
;
UPDATE atable SET cutoff_date = 'xx';
SELECT * FROM atable;
DROP TRIGGER IF EXISTS atable_updated;
CREATE TRIGGER atable_updated AFTER UPDATE ON atable
FOR EACH ROW WHEN last_update != date('now')
BEGIN
UPDATE atable SET cutoff_date = date('now', '-3 days');
END
;
UPDATE atable SET cutoff_date = 'yy';
SELECT * FROM atable;
-- EOF
Here what my Linux with Ubuntu displays upon running it:
...$> ./sqlite3
SQLite version 3.8.1 2013-10-17 12:57:35
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .read bug.script
2013-10-11|2013-10-11
2013-10-19|2013-10-11
Error: near line 26: no such column: last_update
2013-10-19|2013-10-11
sqlite>
I have based it on the Trigger doc. found at:
http://sqlite.org/lang_createtrigger.html
My question:
is this a bug or am I completely misunderstanding
the purpose of the WHEN clause in the trigger syntax?
Thank you for the attention.
Louis Jean-Richard
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users