On 29 Apr 2013, at 7:55pm, Igor Korot <[email protected]> wrote: > Problem is sqlite3_prepare_v2() wastes time by compiling SQL statements and > I'd like to avoid it by making this call only once and just > bind the appropriate parameters on each loop iteration. > > Would it be possible if I make local function variable "static sqlite3_stmt > *stmt;" instead of class member variable? > Problem is in this case I will need 2 of them for each query, right?
Just define and prepare the statement outside of your loop. You can reuse a prepared statement by resetting it. After you've reset it you can leave the existing bindings alone or rebind any variables to new values. See section 3.0 of <http://www.sqlite.org/cintro.html> You can have any number of statements defined and prepared at once. By the way, there is no need to ROLLBACK a statement that fails. A statement that fails, fails. It just does nothing. You might be rolling back other statements in the same transaction but that doesn't seem to be in the code you showed. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

