You could use a trigger...

CREATE TRIGGER increment_numtouched AFTER UPDATE ON TABLE
    BEGIN
        UPDATE TABLE SET numTouched = numTouched + 1 where rowid = old.rowid;
    END;


----- Original Message ----
From: Tito Ciuro <[EMAIL PROTECTED]>
To: Forum SQLite <sqlite-users@sqlite.org>
Sent: Tuesday, March 21, 2006 4:54:03 PM
Subject: [sqlite] Incrementing the value of a column

Hello,

This is the schema: ROWID INTEGER, myText TEXT, numTouched INTEGER

Each time I update a record I'd like to increment its 'numTouched'  
column. I could read the record, retrieve the numTouched value,  
increment it by 1, then update the record with the new text and  
touched values.

Is there a way to do that without SELECT(ing) first the record?

Thanks,

-- Tito



Reply via email to