the code below executes with no errors.
However, when executed twice in a row for two differnet ordinals (with a very small time interval), the first record is deleted, but the second record is not deleted and will show up when the db is reloaded. How do I make sure that the second record is deleted?
wxString command = wxT("DELETE FROM Mouvements WHERE Ordinal = *");
command.Replace(wxT("*"),wxString::Format(wxT("%d"),ordinal));
accountsDB->ExecuteUpdate(command);
wxSQLite3Transaction t(accountsDB);
t.Commit();
raananb wrote:the code below executes with no errors.
However, when executed twice in a row for two differnet ordinals (with a very small time interval), the first record is deleted, but the second record is not deleted and will show up when the db is reloaded. How do I make sure that the second record is deleted?
wxString command = wxT("DELETE FROM Mouvements WHERE Ordinal = *");
command.Replace(wxT("*"),wxString::Format(wxT("%d"),ordinal));
accountsDB->ExecuteUpdate(command);
wxSQLite3Transaction t(accountsDB);
t.Commit();
Without seeing the code how those statements are executed a second time it's hard to tell which actions take place on the database in the end. It could be that the compiler "optimized" your code resulting in wrong behaviour. The wxSQLite3Transaction constructor implicitly opens a transaction.
I would recommend to explicitly start a transaction (using accountsDB->Begin()) and to explicitly commit (using accountsDB->Commit()) instead o wxSQLite3Transaction.
Additionally I would recommend to use a prepared statement (wxSQLite3Statement) to bind the values of ordinal to your SQL statement.