On 8/9/16, Richard Hipp <d...@sqlite.org> wrote:
>
> UPDATE mytable SET counter=remember(counter)+1 WHERE counterid=?
>

Or, you could make remember() a two argument function:

   UPDATE mytable SET counter=remember(counter, $ptr)+1 WHERE counterid=$id

Then bind $ptr to the address of the variable in which you want to
store the original value (and also bind $id to the particular counter
you want to look up, of course).  That way, the same remember()
function could be reused with multiple variables for storing the
result - just rebind the $ptr value each time.

This requires casting a pointer into a 64-bit integer, which is not
guaranteed to work according to various C/C++ standards but which does
in fact work on all modern architectures.
-- 
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

Reply via email to