Android Question RollbackTransaction

b4auser1

Well-Known Member
Licensed User
Longtime User
I didn't find RollbackTransaction method in SQL library, only TransactionSuccessful for commit
B4X:
Public Sub Commit ()
    m_dbSQL.TransactionSuccessful
    m_dbSQL.EndTransaction
End Sub
Could I use the code shown below ?
B4X:
Public Sub Rollback ()
    m_dbSQL.ExecQuery("ROLLBACK")
    m_dbSQL.EndTransaction
End Sub
 

Mahares

Expert
Licensed User
Longtime User
Try something like this:
B4X:
 'Below will not commit, but rolls back
    SQL1.BeginTransaction
    txt="DELETE FROM MyTable WHERE product = 'orange'"
    SQL1.ExecNonQuery(txt)
    txt="ROLLBACK"
    SQL1.ExecNonQuery(txt)

B4X:
 'Below will commit and deletes
    SQL1.BeginTransaction
    txt="DELETE FROM MyTable WHERE product = 'orange'"
    SQL1.ExecNonQuery(txt)
    'txt="ROLLBACK"
    'SQL1.ExecNonQuery(txt)
     SQL1.TransactionSuccessful
     SQL1.EndTransaction
 
Upvote 0
Top