On 2 Aug 2017, at 4:37pm, Sylvain Pointeau <sylvain.point...@gmail.com> wrote:

> Yes I am aware of autoinc but this is not what I can use, because I need to
> specify exactly the sequence (as start number and increment). Additionally
> I can have tables having 2 or 3 fields needing a specified sequence number.

Assuming I understand what you’re asking for, Here are four ways to do this.

First is to set up a TRIGGER which works out the next number in the sequence 
for you.  The TRIGGER would work out MAX(keycol), add the increment to it, and 
use the result to set the value on the new row.

Second is to set a DEFAULT as part of the column definition which does the same 
thing.  (This depends on being able to use MAX() as part of DEFAULT.  I’m 
currently thinking that this is probably not allowed.)

Third is to allow SQLite to set its autoinc value as normal, and calculate the 
key value you want from that and store that in a different column.  You can set 
this key value using a TRIGGER or DEFAULT definition.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to