Re: [sqlite] INTEGER PRIMARY KEY AUTOINCREMENT

2017-06-14 Thread Peter Aronson
On 6/14/2017 5:42 AM, R Smith wrote: On 2017/06/14 7:08 AM, Wout Mertens wrote: Is there a way to specify the starting rowid when using autoincrement? Or should I insert and then remove a row with the id set to one less than the desired id? This is quite easy, but first it is helpful to

[sqlite] INTEGER PRIMARY KEY AUTOINCREMENT

2017-06-14 Thread wout.mertens
Thank you so much all! This mailinglist is amazing :) ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] INTEGER PRIMARY KEY AUTOINCREMENT

2017-06-14 Thread R Smith
On 2017/06/14 7:08 AM, Wout Mertens wrote: Is there a way to specify the starting rowid when using autoincrement? Or should I insert and then remove a row with the id set to one less than the desired id? This is quite easy, but first it is helpful to understand the mechanism by which SQLite

Re: [sqlite] INTEGER PRIMARY KEY AUTOINCREMENT

2017-06-14 Thread J Decker
from https://sqlite.org/autoinc.html On an INSERT, if the ROWID or INTEGER PRIMARY KEY column is not explicitly given a value, then it will be filled automatically with an unused integer, usually one more than the largest ROWID currently in use. This is true regardless of whether or not the

[sqlite] INTEGER PRIMARY KEY AUTOINCREMENT

2017-06-13 Thread Wout Mertens
Is there a way to specify the starting rowid when using autoincrement? Or should I insert and then remove a row with the id set to one less than the desired id? ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-25 Thread Igor Tandetnik
Pavel Ivanov wrote: > Could you explain why this scenario doesn't cause infinite call cycle > of the trigger by itself? Is there some protection in SQLite which > breaks such cycles? SQLite doesn't support recursive triggers: a trigger cannot call itself, directly or indirectly. SQLite keeps

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Dennis Cote
Oliver Peters wrote: > > I want the "normal" user only identify himself by putting his id into > the field identity and afterwards let the system decide in what field to > put his id (INSERT = creator, UPDATE = editor). Doing this for every > record I can show who created it and who was the last

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread João Eiras
On , Pavel Ivanov wrote: > Hi, Richard! > > Could you explain why this scenario doesn't cause infinite call cycle > of the trigger by itself? Is there some protection in SQLite which > breaks such cycles? > Many dbms forbid recursive trigger calls that modify a table that

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Oliver Peters
Am Montag, den 22.06.2009, 17:39 -0600 schrieb Dennis Cote: > Oliver Peters wrote: > > sorry: my code wasn't completely what I wanted so here again: > > > > CREATE TRIGGER IF NOT EXISTS test > > BEFORE INSERT ON "a" > > BEGIN > > INSERT INTO

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Dennis Cote
Oliver Peters wrote: > sorry: my code wasn't completely what I wanted so here again: > > CREATE TRIGGER IF NOT EXISTS test > BEFORE INSERT ON "a" > BEGIN > INSERT INTO a(code,name,creator) > VALUES(new."code",new."name",new."identity"); >

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Pavel Ivanov
Hi, Richard! Could you explain why this scenario doesn't cause infinite call cycle of the trigger by itself? Is there some protection in SQLite which breaks such cycles? Pavel On Mon, Jun 22, 2009 at 4:10 PM, D. Richard Hipp wrote: > > On Jun 22, 2009, at 3:33 PM, Oliver Peters

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread D. Richard Hipp
On Jun 22, 2009, at 3:33 PM, Oliver Peters wrote: > Hello out there, > > > to my mind I get false entries in sqlite_sequence using this code: > > > CREATE TABLE IF NOT EXISTS a( > id INTEGER PRIMARY KEY AUTOINCREMENT, > code

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Oliver Peters
[...] > > The ROWID is not generated until the INSERT statement actually runs. > Hence the BEFORE trigger does not have access to it and the BEFORE > trigger sees a NULL. Change the trigger to an AFTER trigger and it > will work. > [...] > > D. Richard Hipp > d...@hwaci.com Thanks for

Re: [sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread D. Richard Hipp
On Jun 22, 2009, at 3:33 PM, Oliver Peters wrote: > Hello out there, > > > to my mind I get false entries in sqlite_sequence using this code: > > > CREATE TABLE IF NOT EXISTS a( > id INTEGER PRIMARY KEY AUTOINCREMENT, > code

[sqlite] integer primary key autoincrement & sqlite_sequence

2009-06-22 Thread Oliver Peters
Hello out there, to my mind I get false entries in sqlite_sequence using this code: CREATE TABLE IF NOT EXISTS a( id INTEGER PRIMARY KEY AUTOINCREMENT, codeVARCHAR NOT NULL, name