You are not logged in.
How to rollback transaction when it fails to execute BatchSend menthod in server side. Here is my code :
Batch := TSQLRestBatch.Create(RestServer, TMorAssetSplit);
try
AAssetSplit.IDValue := 10000; // I do it on purpose to get Error
Batch.Add(AAssetSplit, True, True);
Batch.Add(AAssetSplit, True, True); // I do it on purpose to get Error
RestServer.BatchSend(Batch);
finally
Batch.Free;
end;
I execute the above code on server. It generates error when trying to save the 2nd AAssetSplit because it has same ID (10000). But when i check in database, the frist AAssetSplit is Saved. How to rollback transaction in batch processing ?
Offline
Enable a transaction during the batch.
How to do it AB ?
Should I change my code to :
Batch := TSQLRestBatch.Create(RestServer, TMorAssetSplit, 5);
try
AAssetSplit.IDValue := 10000; // I do it on purpose to get Error
Batch.Add(AAssetSplit, True, True);
Batch.Add(AAssetSplit, True, True); // I do it on purpose to get Error
RestServer.BatchSend(Batch);
finally
Batch.Free;
end;
Offline
@ab,
I thought even if the AutomaticTransactionPerRow parameter is leaved to 0, a transaction will still be created for the rows being inserted/updated?!
Looks I was wrong...
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Enable a transaction during the batch.
Hi DB I did what you suggested, but I got another trouble. When i enable a transcation during the bact for every 5 rows the application stop / hang when it tries to save the 2nd object, the table may be locked confilict. My Database is MS SQL Server. I can not execute query for this table until i shutdown my application.
I Think mormot fail to rollback transaction.
Offline