Consider this, you have copied a sqlite db to a temporary file. Lets name this temp. sqlite3_stmt *queryStatement = NULL; Now you do a sqlite open to this temp file. prepare a sqlite statement using variable queryStatement. you dont finalize this. Again, you reuse this variable queryStatement for another prepare statement. you only finalize this.