How to submit the delta of the FIREDAC dataset to the middleware and then save into the database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.