Hi guys,
I have a master and child table in server. When insert/update data, to keeps data integrity usually I sent commands to insert/update master child table in a list of commands with ExecuteBatch.
The codes, something look like these
The command ins_master and ins_child are a stored procedure in server without returning any values.
But the problem is, now I need a return values for every succesful ins_child operation.
I can do this by separated ins_master and ins_child operation, ins_master will execute using ExecuteCommand, while ins_child will execute with ExecuteQuery, but this will break data integrity if something goes wrong in one of ins_master/ins_child operations.
Is there a way to handle this situation?
I have a master and child table in server. When insert/update data, to keeps data integrity usually I sent commands to insert/update master child table in a list of commands with ExecuteBatch.
The codes, something look like these
B4X:
Sub SaveData
Private commands As List
commands.Initialize
Private cmd As DBCommand
cmd.Initialize
cmd.Name = "ins_master"
commands.Add(cmd)
Private Cur As Cursor
Cur = Main.SQLMem.ExecQuery("select * from Child")
For i = 0 To Cur.RowCount - 1
Cur.Position = i
Private cmd As DBCommand
cmd.Initialize
cmd.Name = "ins_child"
commands.Add(cmd)
Next
Cur.Close
wait for (reqM.ExecuteBatch(commands,"insert")) JobDone(job As HttpJob)
End Sub
The command ins_master and ins_child are a stored procedure in server without returning any values.
But the problem is, now I need a return values for every succesful ins_child operation.
I can do this by separated ins_master and ins_child operation, ins_master will execute using ExecuteCommand, while ins_child will execute with ExecuteQuery, but this will break data integrity if something goes wrong in one of ins_master/ins_child operations.
Is there a way to handle this situation?