I appreciate the help - I'm new at using triggers.  What I want to
accomplish is:

1. insert if the ip isn't already in the database
2. update the timestamp if the new timestamp after the current
timestamp in the database

what would be the proper trigger to accomplish this task?

Thanks in advance



On Wed, Jun 1, 2011 at 1:22 PM, Igor Tandetnik <itandet...@mvps.org> wrote:
> On 6/1/2011 3:31 PM, Jim Mellander wrote:
>> 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;
>
> This updates all rows, not just the one on which the trigger was fired.
> Is this intentional? You might want something lile
>
> update ip_timestamps set timestamp = OLD.timestamp where rowid = NEW.rowid;
>
> --
> Igor Tandetnik
>
> _______________________________________________
> 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

Reply via email to