On Fri, Aug 04, 2017 at 08:04:38PM +0200, Sylvain Pointeau wrote: > On Fri, Aug 4, 2017 at 6:24 PM, Nico Williams <n...@cryptonector.com> wrote: > > On Fri, Aug 04, 2017 at 06:06:55PM +0200, Sylvain Pointeau wrote: > > > Now I would like to implement the seq_currval: > > we could implement it like (in pseudo code): > > var currvalues = map[string,number] > > function seq_nextval(seq_name) { > update sequence set val = val + inc where name = seq_name > nextval = select val from sequence where name = seq_name > currvalues[seq_name] = nextval > return nextval > } > > function seq_currval(seq_name) { > if currvalues[seq_name] is not set => raise error > return currvalues[seq_name] > }
Sure, but the currvalues[] map has to be store... in the DB handle. You could use a TEMP TABLE, but you'd have to make sure to DELETE all its rows when a transaction ends. > however I noticed that because I am retrieving the params as int64: > '10a' becomes 10, > 'abc' becomes 0 > null becomes 0 > > and I think that is ok, so the SEQ_INIT INTEGER NOT NULL can never be null > and the SEQ_INC can never be 0 due to the check Sure. Nico -- _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users