TZConnection.ApplyUpdates suggestion

Code samples and contributions from users for ZeosLib's DBOs of version 6.x

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
wobben
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 25.09.2008, 11:16
Contact:

TZConnection.ApplyUpdates suggestion

Post by wobben »

Equivalent to the TDbConnection I'm missing a small helper method, which I've reimplemented as a single function.

Code: Select all

procedure TZConnection_ApplyUpdates(aConn: TZConnection; DataSets: array of TZAbstractDataset);
var
  I: Integer;
  DS: TZAbstractDataset;
begin
  aConn.StartTransaction;
  try
    for I := 0 to High(DataSets) do
    begin
      DS := DataSets[I];
      if DS.Connection <> aConn then
        raise EZSQLException.Create(Format(SUpdateWrongDB, [DS.Name, aConn.Name]));
      DataSets[I].ApplyUpdates;
    end;
    aConn.Commit;
  except
    aConn.Rollback;
    raise;
  end;
  for I := 0 to High(DataSets) do
    DataSets[I].CommitUpdates;
end;
Perhaps you may implement this in the next release of ZeosLib. It's a small addition, but helps to transfer existing BDE code into ZeosLib for those, like me, who used to code like this:

Code: Select all

Connection.ApplyUpdates([SomeTxQry, RelatedDetailQry]);
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi Wobben,

Why don't you get your hands dirty and add this method to the TZConnection component. The check for the right datasets could be done using the list FDatasets.

Just write, test and post it here. I'll add the method to SVN (for the next version, not as a patch to current stable branch)

Thanks,

Mark
Image
Post Reply