I am doing a test with Delphi DataSnap REST application. With wizard I can get a good starting point to have a working application between Server and Client. Program codes are shown here.
procedure TServerMethodsMain.ApplyDataSetChanges(const ATableName: String;
const ADeltaList: TFDJSONDeltas);
var
LApply: IFDJSONDeltasApplyUpdates;
begin
LApply := TFDJSONDeltasApplyUpdates.Create(ADeltaList);
DataModule1.FDQuery1.UpdateOptions.UpdateTableName := ATableName;
LApply.ApplyUpdates(ATableName, DataModule1.FDQuery1.Command);
if LApply.Errors.Count > 0 then
raise Exception.Create(LApply.Errors.Strings.Text);
end;
Now here is one issue about data update in server side:
All fields values will be updated together and all OLDVALUEs will be used as reference to identify original record. So, if another user changed one or more values in the same record, client application will generate an error.
I would like to know how to get delta records from TFDJSONDeltas. If so, it will be possible to create an UPDATE SQL with modified values only. And also, record can be identified with primary/key field only.
Thanks.
FireDAC is perfectly capable for generating UPDATE SQL you want. It has lot of options!
Specify FDQuery1.UpdateOptions.KeyFields property and leave FDQuery1.UpdateOptions.UpdateMode to default value upWhereKeyOnly.
Also, Delphi ships with lot of FireDAC samples.