I created a procedure that calls the begin transaction before 3 procedures that make data entry in tables 3. If one of the three procedures is in exception, the rollback does not work.
what am I doing wrong?
See example
where am I wrong? or the system has limits?
thansk
what am I doing wrong?
See example
B4X:
Sub InsertTicketInterventi(aBO As BusinessObject, req As ServletRequest, resp As ServletResponse)
mDB.BeginTransaction
aBO.Master.OkUpdate = True
aBO.Detail.OkUpdate = True
aBO.Summary.OkUpdate = True
'1
If aBO.Master.Fields.Size > 0 And aBO.Master.Name <> "" Then
aBO.Master.OkUpdate = DBUtils.InsertMapsNTransaction(Main.mDB, aBO.Master.Name, aBO.Master.Fields)
' it's ok AND SAVE THE DATA
End If
' 2
If aBO.Master.OkUpdate And aBO.Summary.Fields.Size > 0 And aBO.Summary.Name <> "" Then
Dim aFieldsIntervento As Map
If aBO.Summary.Fields.Size > 0 Then
aFieldsIntervento = aBO.Summary.Fields.Get(0)
End If
' leggo il nuovo
aBO.Summary.IDDocServer = m_IDManager.GetIdNumber(m_IDManager.ID_NumService)
aFieldsIntervento.Put("IDRigaIntervento", aBO.Summary.IDDocServer)
aBO.Summary.OkUpdate = DBUtils.InsertMapsNTransaction(Main.mDB, aBO.Summary.Name, aBO.Summary.Fields)
' it's ok AND SAVE THE DATA
End If
'2
If aBO.Master.OkUpdate And aBO.Detail.Fields.Size > 0 And aBO.Detail.Name <> "" Then
DBUtils.DeleteRecord( Main.mDB, aBO.Detail.Name, aBO.Detail.WhereUpdateFields)
For i = 0 To aBO.Detail.Fields.Size - 1
Dim aRecord As Map = aBO.Detail.Fields.Get(i)
aRecord.Put("IDRigaIntervento", aBO.Summary.IDDocServer)
Next
' it's NOT OK
aBO.Detail.OkUpdate = DBUtils.InsertMapsNTransaction(Main.mDB, aBO.Detail.Name, aBO.Detail.Fields)
End If
' CHECK FALSE
If aBO.Master.OkUpdate And aBO.Detail.OkUpdate And aBO.Summary.OkUpdate Then
Main.mDB.TransactionSuccessful
Else
' CALL ROLLBACK - BUT THE DATA SAVED IN 1 AND 2 POINT REMAIND SAVED IN THE TABLET
' I EXPECT THAT IS MADE THE ROLLING BACK THE DATABASE AND REMOVE THE DATA...
Main.mDB.Rollback
End If
Main.SendObjectReturnToSend(aBO, resp.OutputStream)
End Sub
where am I wrong? or the system has limits?
thansk