SQLite Forum

Nesting of statements
Login
You cannot call sqlite3_finalize() on a connection, only on a statement.

The first call to sqlite3_step() on the SELECT statement creates a transaction.

This is kept open (and upgraded to a write transaction) when your UPDATE statement is prepared/stepped/finalized within sqlite3_exec.

You are losing performance here by repreparing the same UPDATE over and over instead of just once(outside the loop) and calling bind() and step() inside.

The transaction is terminated automatically when the SELECT completes.

Please note that you need to check the return status of all function calls.