A sequence is very easily implemented as a virtual table that keeps the current values in a separate table my_sequences (name text primary key, initial integer, current integer, increment integer).
CREATE VIRTUAL TABLE seq_1 USING sequence ([<initial>[,<increment>]]); -- defaults 1, 1 The xCreate/xConnect function just needs to store its name and set a DDL like CREATE TABLE X (current_value integer, next_value integer); The xColumn function just needs to run one of two statements: For field next_value run the following statement and fall through to current_value: UPDATE my_sequences SET current = current + increment WHERE name='<sequence_name>'; For field current_value: SELECT current FROM my_sequences WHERE name='<sequence name>'; You could also implement a virtual field rewind UPDATE my_sequences SET current = initial WHERE name='sequence_name'; Or whatever else tickles your fancy. Just think table <=> class, virtual field <=> method -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Sylvain Pointeau Gesendet: Mittwoch, 02. August 2017 21:07 An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Betreff: Re: [sqlite] sequencer ok thank you for the confirmation, I will try implementing it in a dll using UD functions and put it on github. Le mer. 2 août 2017 à 20:56, Richard Hipp <d...@sqlite.org> a écrit : > On 8/2/17, Sylvain Pointeau <sylvain.point...@gmail.com> wrote: > > > > is it really possible to make an update into that nextval function? > > I > don't > > think so since only one statement can be run at the same time if > > sqlite > is > > in serialized mode. > > "serialized" means that multiple threads cannot be making updates at > the same time. In this case, the update would be happening in the > same thread. > > -- > D. Richard Hipp > d...@sqlite.org > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: h...@scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users