Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-10 Thread Simon Slavin
On 10 Mar 2011, at 7:57am, Mohd Radzi Ibrahim wrote: > So, that's explain why my column ID INTEGER PRIMARY KEY, changes when I use > REPLACE. I could not rely on the ID with this command. Yes. You explicitly said 'REPLACE' so that's what it's doing. If you want to modify an existing

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Mohd Radzi Ibrahim
On 10-Mar-2011, at 6:52 AM, Jay A. Kreibich wrote: > On Wed, Mar 09, 2011 at 11:37:46PM +0100, Armin Kunaschik scratched on the > wall: >> On Wed, Mar 9, 2011 at 11:28 PM, Igor Tandetnik wrote: > >>> INSERT OR REPLACE is indistinguishable from a DELETE followed by INSERT.

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Jay A. Kreibich
On Wed, Mar 09, 2011 at 11:37:46PM +0100, Armin Kunaschik scratched on the wall: > On Wed, Mar 9, 2011 at 11:28 PM, Igor Tandetnik wrote: > > INSERT OR REPLACE is indistinguishable from a DELETE followed by INSERT. > Is it really DELETE and INSERT internally? Yes and no.

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Armin Kunaschik
On Wed, Mar 9, 2011 at 11:44 PM, Simon Slavin wrote: > > On 9 Mar 2011, at 10:37pm, Armin Kunaschik wrote: > >> Is it really DELETE and INSERT internally? > > As far as you can tell when how SQLite behaves, yes it is. > >> This would explain, why ctime is "invisible" inside

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Simon Slavin
On 9 Mar 2011, at 10:37pm, Armin Kunaschik wrote: > Is it really DELETE and INSERT internally? As far as you can tell when how SQLite behaves, yes it is. > This would explain, why ctime is "invisible" inside the trigger... > it's simply not there > when replace is used. > > Maybe I should

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Jay A. Kreibich
On Wed, Mar 09, 2011 at 11:19:51PM +0100, Armin Kunaschik scratched on the wall: > Important: I also want to be able to "insert or replace" rows and keep ctime. > The update trigger works fine, but the insert trigger ALWAYS updates ctime. As Igor pointed out, "INSERT OR REPLACE" is called

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Armin Kunaschik
On Wed, Mar 9, 2011 at 11:28 PM, Igor Tandetnik wrote: > On 3/9/2011 5:19 PM, Armin Kunaschik wrote: >> I'm trying this for quite some time... and I'm totally stuck. >> >> I have the following table: >> >> CREATE TABLE example( >>   date integer primary key not null, >>  

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Igor Tandetnik
On 3/9/2011 5:19 PM, Armin Kunaschik wrote: > I'm trying this for quite some time... and I'm totally stuck. > > I have the following table: > > CREATE TABLE example( > date integer primary key not null, > text text, > ctime TIMESTAMP, > mtime TIMESTAMP); > > ctime=creation time (should be

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Armin Kunaschik
On Wed, Mar 9, 2011 at 11:21 PM, Mr. Puneet Kishor wrote: > > On Mar 9, 2011, at 5:19 PM, Armin Kunaschik wrote: > >> Hi there, >> >> I'm trying this for quite some time... and I'm totally stuck. >> >> I have the following table: >> >> CREATE TABLE example( >>  date integer

Re: [sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Mr. Puneet Kishor
On Mar 9, 2011, at 5:19 PM, Armin Kunaschik wrote: > Hi there, > > I'm trying this for quite some time... and I'm totally stuck. > > I have the following table: > > CREATE TABLE example( > date integer primary key not null, > text text, > ctime TIMESTAMP, > mtime TIMESTAMP); > >

[sqlite] Creation and modification timestamps with "insert or replace" possible?

2011-03-09 Thread Armin Kunaschik
Hi there, I'm trying this for quite some time... and I'm totally stuck. I have the following table: CREATE TABLE example(  date integer primary key not null,  text text,  ctime TIMESTAMP,  mtime TIMESTAMP); ctime=creation time (should be set only once) mtime=modification time (should be set