> CREATE TRIGGER ts_update after update on ip_timestamps when This means that your trigger fires after each UPDATE statement. But
> I'm adding/updating records with statements like: > > INSERT OR REPLACE into ip_timestamps VALUES ( "182.71.33.222" , 1306932777 ); you do INSERT statements, so your trigger is never executed. Don't be confused: REPLACE means that if needed the old row is deleted and new is inserted. Row is never updated and UPDATE triggers are never executed (I'm not sure about DELETE and INSERT triggers though). Pavel On Wed, Jun 1, 2011 at 3:31 PM, Jim Mellander <jmellan...@lbl.gov> wrote: > 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