0

We have a FDquery with calculated fields on a datasnap server.

When openeing the Query on a client with a FDMemtable, the calculated fields are empty.

Q: How can we send the calculated data through datasnap to the client?

function TCOMServerMethods.QRY_Get(): TFDJSONDataSets;
begin
  result:=TFDJSONDataSets.Create;      
    FDQRY.Close;
    //SQL
    FDQRY.Open;        
  TFDJSONDataSetsWriter.ListAdd(result,'TABLENAME',FDQRY);       
end;


procedure TCOMServerMethods.FDQRYCalcFields(DataSet: TDataSet);
begin
  inherited;     
  //Add calculated value
  FDQRYCalcField.Value:='Calculated'    
end;
r_j
  • 1,348
  • 15
  • 35
  • 2
    Can you try making it an _fkInternalCalc_ field? Make sure that the _OnCalcFields_ event checks for `State = dsInternalCalc` when setting that field. – Uwe Raabe Jul 13 '17 at 12:20
  • 1
    Shouldn't you have the calculated field on the client instead of the server ?. – Marc Guillot Jul 13 '17 at 12:22
  • The calculations are done on the server. This is a migration from TClientdataset with datasetprovider to FDMemtable with JSON so we can't afoord to change all logic – r_j Jul 13 '17 at 12:27
  • @MarcGuillot, that's correct. Calculated fields are volatile and don't store their values. So they would only make sense at the client here. But the intention seems to be different. – Uwe Raabe Jul 13 '17 at 12:27
  • Not all information is known to the client so I need to calculate the fields on the Server. There is more to it then just adding two string columns together. – r_j Jul 13 '17 at 12:50
  • In this case I would probably try a second MemTable on the Server, and use the CopyDataset method from the original MemTable to Copy all your data (calculated fields included) to normal fields before sending it to the Client. – Marc Guillot Jul 14 '17 at 06:31

0 Answers0