NEW.timestamp < OLD.timestamp (less than)?
-----Original Message----- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Jim Mellander Sent: Wednesday, June 01, 2011 3:31 PM To: General Discussion of SQLite Database Subject: [sqlite] Trigger help needed Hopefully someone can help me with this I have a table with IP addresses and timestamps - I want to update the table when the new timestamp is later than the old one $ sqlite3 test.db SQLite version 3.7.4 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .schema CREATE TABLE ip_timestamps (ip text unique, timestamp date); CREATE UNIQUE INDEX ip_index on ip_timestamps (ip ASC); CREATE TRIGGER ts_update after update on ip_timestamps when NEW.timestamp < OLD.timestamp BEGIN update ip_timestamps set timestamp = OLD.timestamp; END; I'm adding/updating records with statements like: INSERT OR REPLACE into ip_timestamps VALUES ( "182.71.33.222" , 1306932777 ); The goal is to keep the latest timestamp in the database (the older timestamp could occur later in the input than the newer timestamp), but the trigger doesn't seem to be working - I assume the trigger is flawed. Any suggestions? Thanks in advance. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users