Datasnap data submitted by FIREDAC Tfdjsondeltas

Source: Internet
Author: User

Datasnap data submitted by FIREDAC Tfdjsondeltas

FIREDAC's Tfdjsondeltas is equivalent to the delta of Clientdataset, appearing as a substitute for Clientdataset.delta.

Tfdjsondeltas is a collection of multiple dataset deltas that can submit modified data from multiple datasets to the database at once.

Service-Side code:

function Tservermethods1.savedata2 (const ACCOUNTNO, tablename:string; delta:tfdjsondeltas): Boolean;
Var
D:tfrmdb;
Lapply:ifdjsondeltasapplyupdates;
Begin
Result: = False;
if (Accountno = ") or (TableName =") or (delta = nil) Then
Exit;
D: = Getdbpool (Accountno). Lock;
If not Assigned (d) Then
Exit;
Try
Try
Settraceon (d);
D.qryopen.close;
D.qryopen.sql.clear;
D.qryopen.sql.text: = ' select * from ' + TableName + ' where 1=2 ';
D.qryopen.open;
Lapply: = tfdjsondeltasapplyupdates.create (delta);
Lapply.applyupdates (0, D.qryopen.command);
Result: = LApply.Errors.Count = 0;
Except
On E:exception do
Begin
Result: = False;
Log.writelog (' tservermethods1.savedata2 ' + e.message);
End
End
Finally
D.qryopen.close;
Getdbpool (Accountno). Unlock (d);
Settraceoff (d);
End
End

Client code:

Procedure Tform1.btnsave2click (Sender:tobject);
Var
Ldeltas:tfdjsondeltas;
Begin
If fdmemtable1.state in dseditmodes then//commit modifications to the memory table
Fdmemtable1.post
Else
Exit;
Ldeltas: = tfdjsondeltas.create;
Tfdjsondeltaswriter.listadd (Ldeltas, ' 1 ', FDMemTable1);
If methods. SaveData2 (' 0 ', ' t1 ', Ldeltas) then
Self.caption: = ' Save OK '
Else
Self.caption: = ' save fail ';
End

Datasnap data submitted by FIREDAC Tfdjsondeltas

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.