I am doing test with Delphi DataSnap REST application. I have tried this tutorial from Embarcadero and it works for simple table and one join SQL query.
// simple table sample
V001.SQL.Text := 'Select * from T001 where K010=:XK010';
// one join query
V001.SQL.Text :=
'SELECT T001.K001 AS K001, T001.K010 AS K010, '
+ 'T001.F001 AS F001, T010.F001 AS F002 '
+ 'T001.F001 AS F001, T010.F001 AS F002 '
+ 'FROM T001 LEFT JOIN T010 ON T001.K010 = T010.K010 '
+ 'WHERE T001.K010=:XK010 '
+ 'ORDER BY T001.F001';
Now I start to try this sample with two joins query and get error at ApplyUpdates procedure.
// two joins query
V001.SQL.Text :=
'SELECT T001.K001 AS K001, T010.F002 AS T010F002, '
+ 'T016.F002 AS T016F002, '
+ 'T001.F001 AS F001, T001.K010 AS K010, T001.K016 AS K016 '
+ 'FROM ((T001 LEFT JOIN T010 ON T001.K010 = T010.K010) '
+ ' LEFT JOIN T016 ON T001.K016 = T016.K016) '
+ 'WHERE T001.K010=:XK010 '
+ 'ORDER BY T001.F001';
procedure TServerMethods1.ApplyChangesSupplierProduct(const ADeltaList: TFDJSONDeltas);
var
LApply: IFDJSONDeltasApplyUpdates;
sText: String;
begin
// Create the apply object
LApply := TFDJSONDeltasApplyUpdates.Create(ADeltaList);
// Apply the supplier delta
LApply.ApplyUpdates(myJoinQuery, V001.Command);
if LApply.Errors.Count > 0 then
// Raise an exception if any errors.
raise Exception.Create(LApply.Errors.Strings.Text);
end;
As my SQL example with two joins shown above, error happens at the line of LApply.ApplyUpdates(myJoinQuery, V001.Command)
.
Please anyone show me some advice about how to get this work or if I need to prepare V001.Command
by myself and how.
Thanks in advance.