Hello guys,
I have a code to insert/update hundreds of rows. In order to keep the integrity, insert/update operation made within BeginTransaction and TransactionSuccessful/Rollback.
But I have a problem, there are records which values depend on values on other values that still not committed because it is in the same BeginTransaction - TransactionSuccessful loop.
Here are the sample code
The value of variable Id was not 1, cause it was not committed yet, so the command to update tbl2 will always never executed.
Is there any way to solve this ?
I have a code to insert/update hundreds of rows. In order to keep the integrity, insert/update operation made within BeginTransaction and TransactionSuccessful/Rollback.
But I have a problem, there are records which values depend on values on other values that still not committed because it is in the same BeginTransaction - TransactionSuccessful loop.
Here are the sample code
B4X:
Private dbpool As ConnectionPool
dbpool.Initialize(...)
Private Qry1,Qry2 As SQL
Private Id as int
Qry1 = dbpool.GetConnection
Qry2 = dbpool.GetConnection
Qry1.BeginTransaction
Qry1.ExecNonQuery("update tbl1 set field1 = 1")
Id = Qry2.ExecQuerySingleResult(select field1 from tbl1)
if Id = 1 then Qry1.ExecNonQuery("update tbl2 set field2 = 10")
Qry .TransactionSuccessful
The value of variable Id was not 1, cause it was not committed yet, so the command to update tbl2 will always never executed.
Is there any way to solve this ?