logo       

Re: Emulating a sequence: msg#00017

python.db.pysqlite.user

Subject: Re: Emulating a sequence


Tim Golden wrote:
> David Pratt wrote:
>> I was thinking about faking a sequence. My first thought was to
>> create a sequence table with a single row where a field is a sequence
>> value and you just increment the value and retreive it as anything else.
>> It's simple but particulary good.

Eesh! I meant to say not particularly good. I guess it was late when I
wrote this.

> No comment as such on the sequence class (never
> tried it myself). I just wanted to make sure
> you did know about sqlite's automatic autoincrement
> value. I know it's not the same as a sequence, but
> in case you were simply trying to achieve the same
> effect...

Hi Tim. I am aware of autoincrementing and have been using it (see tid
below). I still need something to emulate a sequence. The field I need a
sequence for is not the primary key. It is a field that keeps track of
the commit_order for a type of transaction.

ie.
create table ztransaction (
tid integer not null primary key,
packed boolean not null default false,
commit_order integer not null unique,
more fields ...
);

Hopefully there are a few ideas out there. I'll have to finalize on one
today in any case :-)

Regards
David


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise