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
/*
: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
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 approa
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
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 */
BEGIN;
CREATE TABLE id_allocator(id INTEGER PRI
> > /* 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
> 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 tran
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 by
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 id_allocator(0)
9 matches
Mail list logo