Re: [sqlite] Trigger help needed

2011-06-01 Thread Jim Mellander
Thanks - and with a little reading of the manpages, understandable too Appreciate it. On Wed, Jun 1, 2011 at 2:34 PM, Igor Tandetnik wrote: > On 6/1/2011 5:23 PM, Jim Mellander wrote: >> I appreciate the help - I'm new at using triggers.  What I want to >> accomplish is: >> >> 1. insert if t

Re: [sqlite] Trigger help needed

2011-06-01 Thread Igor Tandetnik
On 6/1/2011 5:23 PM, Jim Mellander wrote: > 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 Something like this, pe

Re: [sqlite] Trigger help needed

2011-06-01 Thread Jim Mellander
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

Re: [sqlite] Trigger help needed

2011-06-01 Thread Igor Tandetnik
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 >

Re: [sqlite] Trigger help needed

2011-06-01 Thread Pavel Ivanov
> 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 you

Re: [sqlite] Trigger help needed

2011-06-01 Thread Michael Stephenson
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 nee

[sqlite] Trigger help needed

2011-06-01 Thread Jim Mellander
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 C