Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-10 Thread Stephen J. Lombardo
will probably end-up using something like the scheme offered below :-) -Clark - Original Message From: Dan Kennedy <[EMAIL PROTECTED]> To: sqlite-users@sqlite.org Sent: Thursday, October 06, 2005 09:42:32 Subject: RE: [sqlite] Maintaining a sequence that's not rowid /* Retrieve n

Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-07 Thread Clark Christensen
:42:32 Subject: RE: [sqlite] Maintaining a sequence that's not rowid > > /* Retrieve next id in sequence: */ > > BEGIN; > > SELECT id FROM id_allocator; /* This is the id to use */ > > UPDATE id_allocator SET id = id + 1; > > COMMIT; /* Can't use the i

Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Jay Sprenkle
On 10/6/05, Darren Duncan <[EMAIL PROTECTED]> wrote: > > > I'm inclined to think that this is a bad idea by itself because your > id_allocator table ends up with a large number of records in it, one > per increment, which take up space but don't serve a useful purpose. > Whereas, an updating

Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Darren Duncan
At 11:13 AM -0700 10/6/05, Antony Sargent wrote: Alternatively, you might consider making the id_allocator table have an auto-increment primary key, and then insert null to have sqlite generate id's for you, and use last_insert_rowid() to find out the value it generated. /* Initialize system

RE: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Dan Kennedy
> > /* Retrieve next id in sequence: */ > > BEGIN; > > SELECT id FROM id_allocator; /* This is the id to use */ > > UPDATE id_allocator SET id = id + 1; > > COMMIT; /* Can't use the id until the transaction successfully commits! > > */ > > Just a side note; Traditionally this is

RE: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Clark, Chris M
> From:Dan Kennedy [mailto:[EMAIL PROTECTED] > Sent:Wed 10/5/2005 11:30 PM > /* Retrieve next id in sequence: */ > BEGIN; > SELECT id FROM id_allocator; /* This is the id to use */ > UPDATE id_allocator SET id = id + 1; > COMMIT; /* Can't use the id until the

Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Jay Sprenkle
On 10/5/05, Clark Christensen <[EMAIL PROTECTED]> wrote: > > In my app (a perl/web-based on-line training system), I have a table of > users with an integer primary key column, tech_id. The tech_ids are created > by a foreign system, and either imported with other data, or inserted > as-received

Re: [sqlite] Maintaining a sequence that's not rowid

2005-10-06 Thread Dan Kennedy
I think what you propose will work fine, but you could just do it all yourself with some SQL. Arguably clearer, and no messing about with complex, possibly non-portable, triggers + auto-increments. /* Initialize system */ BEGIN; CREATE TABLE id_allocator(id INTEGER); INSERT INTO

[sqlite] Maintaining a sequence that's not rowid

2005-10-05 Thread Clark Christensen
In my app (a perl/web-based on-line training system), I have a table of users with an integer primary key column, tech_id. The tech_ids are created by a foreign system, and either imported with other data, or inserted as-received by my app. In enhancing the app, I'm finding it desirable