Jump to content
Jasonjac2

TFDBatchMove.OnFindDestRecord dest.next does nothing - why?

Recommended Posts

Following on from the linked question. I have put some debug code in to try and optimize the locate - see below.

 

procedure TfrmMain.FDBatchMove1FindDestRecord(ASender: TObject; var AFound:
    Boolean);
begin
  mmInfo.lines.Add('Find: src.ID: '+tblsrcWebUsersid.AsString+' current dest.id: '+tbldestWebUsersid.AsString);

  afound:=(tblsrcWebUsersID.value = tbldestWebUsersID.value);
  if afound then
    mmInfo.lines.Add('Found: ID: '+tblsrcWebUsersid.AsString+' over correct record')
  else
  begin
    tbldestWebUsers.next;   //this command does nothing, i.e. it doesn't move the cursor
    afound:=(tblsrcWebUsersID.value = tbldestWebUsersID.value);
    if afound then
      mmInfo.lines.Add('Found: ID: '+tblsrcWebUsersid.AsString+' was next record')
    else
    begin
       afound:=tbldestWebUsers.locate('ID',tblsrcWebUsersid.value,[]);
       if afound then
         mmInfo.lines.Add('Found: ID: '+tblsrcWebUsersid.AsString+' using locate')
       else
         mmInfo.lines.Add('Not Found: ID: '+tblsrcWebUsersid.AsString+' using locate');
    end;

  end;
end;

Just to be clear - it works without the code above (2 x FDTables looking at the same table structure is 2 different SQlite DBS)

basically as the execute steps through the source table the destination is always (if both have the same PK's and rows) one record behind after the first row. 

So I thought I could do the code above to try and do a next rather than a locate in nearly all cases.

The .next does nothing though. I have traced the code to

image.thumb.png.c8388131df47b09143c89d106df59278.png

 

and in here it, I am not sure what is going on, but the result is that the cursor doesn't move. 

 

Does anyone know why?

Who are the Batchmove gurus?

D12.1

TIA JAC

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×