SQLite Forum

table locked when dropping a temp table
Login
I can't solve the locking problem but I came up with a faster, more efficiant, way to do what you want.  One that won't require a temp table.

Instead of creating a temp table, add a column to your existing table.  Call it tempOrder.  When you want to do the increment do this:

<code>UPDATE variables SET tempOrder = order + 1 WHERE order >= orderLimit;
UPDATE variables SET order = order + 1000000 WHERE orde r>= orderLimit;
UPDATE variables SET order = tempOrder, tempOrder = NULL WHERE order >= orderLimit;</code>

You may or may not need the second line depending on how SQLite works.  But even with it, those three lines take less time to execute than the version which requires a new table.

By the way, try not to have both a column and a variable with the same name.  It makes your code difficult to understand.