IndexDefs not (always?) accurate after TDAMemDataset.RefreshFromServer

Hello there,

I’m currently writing a WindowsService to sync some tables between databases. There’s one table which contains a list of produced items with at least two columns: ID (LargeAutoInc) and a serial number (Unique!).

In order to replicate tables with foreign keys on that Table-ID correctly I wrote a function to lookup the DatabaseB.ID for a given DatabaseA.ID (via Serial Number, tiTableInfo holds that information…).

Therefore I have to incrementally load rows for both databases.

While developing this service I had a lot of debug-output written to a text file and everything worked as expected. However after removing this debug output I run into a problem with the following:

[..] dtMapSource.DynamicWhere.Clear; dtMapSource.DynamicWhere.Expression := DAWhereValue( '', tiTableInfo.MapperTableField, vMappedValue );
  if dtMapSource.Active then
    dtMapSource.RefreshFromServer
  else
    dtMapSource.Open;

  //if here occurs something, e.g. write log message to a file
  //the error will not occur


  //--> if I'm using LocateByIndex the row may not be found... I don't know why...
  //if NOT dtMapSource.LocateByIndex( tiTableInfo.MapperTableField, vMappedValue ) then
  if NOT dtMapSource.Locate( tiTableInfo.MapperTableField, vMappedValue, [] )  then
      raise Exception.Create( 'GetMappedID.' + sTablename + ': Could not find row for source value ' + VarToStr( vMappedValue ) + ', ' + dtMapSource.DynamicWhere.Xml );
  [..]

The problem didn’t occur until i removed the output to the logfile… If I’m using .Locate instead of .LocateByIndex everythings fine.

How and when are the indizes of a TDAMemDataset refreshed and/or can I enforce an Update (IndexDefs.Update did not solve the problem)?
This method is part of a thread within a windows-service (with connections to multiple DA-Servers).
The tables are not in any special state (ControlsDisabled and so on…)

Thanks in advance,
Peter

Hello,

I can’t reproduce this situation with simple DA application. If I understand you right your WindowsService application is not a DA server, it is just connected to the DA servers. Is it organized like DA client? Please, descibe it in details or better send testcase reproducing situation.

Best regards

Hi again,

maybe I’ve some time after easter to send a little testcase… Is it possible to attach a file as non-public?

I’ve currently implented the lookup using a TDictionary which scales much better (and does not have to above problem) for looking up existing and new rows.

As for this (windows-)service: yes, it is a TServiceApplication which acts (for the DA-Server) as a normal client. Every possible task is in a seperate thread and has own connections to the DA-Server (the replication is just one thread/task). For debugging reasons I’m just calling TServiceApplication.ServiceStart(…) and TServiceApplication.ServiceStop directly instead of TSA.Run().

Best regards,
Peter

pmatjeschk said: Is it possible to attach a file as non-public?

You can send it to support@remobjects.com