> Wrap the above two statements in:
>
> 0) BEGIN EXCLUSIVE
> ...
> 3) COMMIT
>
> The BEGIN EXCLUSIVE above is all you need (and more, a simple BEGIN
> may be enough).
>
> > Can someone with more knowledge of SQLite internals explain the
> > right way to "atomic"-lly "pop"-off an item from table in SQlite?
> > (And, in this case, also add it to a 2nd table.)
>
> The above sequence of 4 statements is atomic.
>
Thank you.
I missed the EXCLUSIVE clause in the docs.... comes with the newbie territory,
i guess.
So to confirm, would something like this work?
Tables:
task_log => (id, task_data, time_stamp)
task_fifo = > (id, fk_task_log)
task_status_log => (id, fk_task_log, status_code, time_stamp)
And in psudo SQL:
TRIGGER ON INSERT INTO task_log:
BEGIN
INSERT INTO task_fifo (fk_task_log) VALUES (NEW.id)
END;
And then, again in psudo SQL, the worker does something like:
BEGIN EXCLUSIVE TRANSACTION;
INSERT INTO task_status_log FROM SELECT OLDEST IN task_fifo ;
DELETE FROM task_fifo OLDEST;
COMMIT;
Is there a better way to do this? (views?)
Thanks again,
:)
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users