You can send the sequence stream to the middleware at the delta of the client sequence FIREDAC dataset,
The Tfdquery or tfdmemtable of the middleware calls the Loadfromstream () method to load the stream,
Then call Applyupdates () to save the data into the database.
How do I convert the delta of Tfdquery or tfdmemtable to stream?
You will need to set fdquery or tfdmemtable resourceoptions.storeitems for [Sidelta] or [Simeta, Sidelta].
Then call the Savetostream () method.
Here is the code for the demo:
Var
Stream:tmemorystream;
Begin
Qrydatasource has records,modified 1 record,so have 1
Delta Record
Stream: = tmemorystream.create;
QryDataSource.ResourceOptions.StoreItems: =
[Sidata,simeta,sidelta];
Stream: = tmemorystream.create;
Qrydatasource.savetostream (Stream);
Restore Storeitems
QryDataSource.ResourceOptions.StoreItems: =
[Sidata,simeta,sidelta];
Stream.position: = 0;
Remote App,transports Stream by HTTP
Qryremote.close;
Qryremote.cachedupdates: = True;
QryRemote.UpdateOptions.KeyFields: = ' ID ';
QryRemote.UpdateOptions.UpdateTableName: = ' bas_colors ';
QryRemote.SQL.Text: = ' select * from bas_colors where 1=0 ';
QryRemote.ResourceOptions.StoreItems: = [Simeta,sidelta,sidata];
It load Reocrds,not only 1 Delta record
Qryremote.loadfromstream (Stream);
Stream.free;
Commit and Refresh
Qryremote.applyupdates ();
Qrydatasource.commitupdates;
Qrydatasource.refresh;
End
How to submit the delta of the FIREDAC dataset to the middleware and then save into the database