Is it possible ApplyUpdates is changing the current record?

I have a very strange issue which, looking at my code, shouldn’t be possible, unless…

Is it all possible for the ApplyUpdates call to change the current record?

If I have a data table and I append a new record to it (which thus becomes the current record), then call ApplyUpdates, can I guarantee that the new record will still be the current one or is there any chance it could have changed?

Basically I’m using the newly created primary key for the added record after the ApplyUpdates call (MSSQL IDENTITY column) but the issue I’m seeing can only be explained if the data table’s current record was moved so the new record is no longer the current one, thus meaning I end up using the Id of a different record.


Can you specify your platform (Delphi, .NET, etc), pls?

Sorry, it’s Delphi.

I notice there’s a ReturnToCurrentRecord parameter on TDADataTable.ApplyUpdates which I’d never noticed before and which defaults to False.

Should I be using this and what are the implications if I don’t?

EDIT: One further bit of info which could be relevant. I’m actually appending a new record to a detail table and then calling ApplyUpdates on the master? Could this cause the current detail record to change?

Ok, from my own investigations:

It appears I should be using the ReturnToCurrentRecord parameter if I want to ensure that the current record doesn’t change. Omitting it, as I currently do, seems to work anyway but I’m not sure if this can be relied upon?

Also, this parameter doesn’t affect detail tables. Even if I set the parameter for an ApplyUpdates call on the master table, I can’t be sure that the detail table(s) will have the same current record. Where I need to rely on this, it seems a direct call to ApplyUpdates on the detail table with the parameter set to True is the safest option.

Are my findings/assumptions correct?

if ReturnToCurrentRecord is set, it performs Locate after ApplyUpdate

yes, it will have effect because after changing of master (we locate master record in MergeDelta via First & Locate), 1st row of detail table will be selected