Re: [sqlite] Re: [2.8.x] Incrementing a column automatically with INSERT/UPDATE?

2007-08-05 Thread Gilles Ganault
At 02:21 06/08/2007 +0200, you wrote: I'm sorry to bother you again, but I can't figure out how to write a trigger that will set a column to 1 when a user creates a new record :-/ Found it in "Sam's Sqlite (2004)": CREATE TRIGGER insert_mytable_timestamp AFTER INSERT ON mytable BEGIN

Re: [sqlite] Re: [2.8.x] Incrementing a column automatically with INSERT/UPDATE?

2007-08-05 Thread Gilles Ganault
Hello At 15:28 04/08/2007 -0400, you wrote: UPDATE mytable SET timestamp = old.timestamp + 1 WHERE rowid=new.rowid; I'm sorry to bother you again, but I can't figure out how to write a trigger that will set a column to 1 when a user creates a new record :-/ I tried the following but

Re: [sqlite] Re: [2.8.x] Incrementing a column automatically with INSERT/UPDATE?

2007-08-04 Thread Gilles Ganault
At 15:28 04/08/2007 -0400, Igor Tandetnik wrote: UPDATE mytable SET timestamp = old.timestamp + 1 WHERE rowid=new.rowid; Great :-) Thanks a lot. For those interested in doing the same thing: = create table mytable (id INTEGER AUTO PRIMARY KEY, name VARCHAR(50), timestamp

[sqlite] Re: [2.8.x] Incrementing a column automatically with INSERT/UPDATE?

2007-08-04 Thread Igor Tandetnik
Gilles Ganault wrote: So, I guess the solution is to write a trigger. Problem is, I've never used triggers before, so I don't really know how to get around to fetching the previous value of a timestamp column and increment it whenever a record is updated: CREATE TRIGGER update_timestamp