function TSLPW_Service.ApplyUpdates(var ADeltaArray: DaltaArray): Boolean;
//多Clientdatasets的更新
var
I : integer;
Provider : TdataSetprovider;
ErrorCount : integer;
aTD: TDBXTransaction;
begin
ApplyUpdates := True;
with Unit_dm.RODataSnapModule_DM do
begin
if SQLConnection.InTransaction then
begin
ShowMessage('数据库服务忙,请稍候保存');
exit;
end;
aTD := SQLConnection.BeginTransaction(TDBXIsolations.Serializable);
try
{here is your code}
for I := 0 to ADeltaArray.Count - 1 do
begin
Provider := FindProvider(ADeltaArray[I].ProviderName);
if not Assigned(Provider) then
raise Exception.Create('Provider not found:'+ AdeltaArray[I].ProviderName);
Provider.ApplyUpdates(VariantFromBinary(AdeltaArray[I].Delta),0,ErrorCount);
if ErrorCount > 0 then
raise Exception.Create('Err During applyupdates:'+Provider.Name);
end;
SQLConnection.CommitFreeAndNil(aTD);
except
on e: Exception do
begin
ShowMessage(e.message);
SQLConnection.RollbackFreeAndNil(aTD);
ApplyUpdates := False;
end;
end;
end;
end;
RemObject 在一个事务中实现多个clientdataset的更新
最新推荐文章于 2024-06-18 11:05:12 发布