Update data from multiple tables to the kbmmw server by client using transactions. You can use tkbmmwclienttransactionresolve to submit multiple modified datasets to the server at a time. The server uses transactions to update data, commit the transaction. If the transaction fails, the rollback transaction will be performed. In actual development, you may need to execute separate SQL statements to process the business logic while updating the dataset. The method is to use a separate tkbmmwclientquery. Usage:
Kbmmwclietnquery3.query. Text: = 'Update T1 set F2 = 1 where F1 = 1 ';
Kbmmwclientquery3.transactionoperation: = mwtoexecute; // you must set this dataset to execute the SQL statement.
Then, use kbmmwclienttransactionresolve to submit together with the updated Dataset:
Kbmmwclienttransactionresolver1.resolve ([kbmmwclientquery1, kbmmwclientquery2, kbmmwclientquery3]);
Query1, query2 are the dataset, and query3 are the executed SQL.
So what should I do if there are multiple SQL statements to execute? Like above, I use query4, query5... and other methods to submit SQL statements?
In fact, kbmmw provides a better method for us, that isSQL separator.
Exclamation point! : Separate multiple SQL statements to be executed
Equal Sign =: Separate multiple SQL statements to return results (this method does not come up with an application scenario)
Take a look at the specific usage:
Use query3 to execute two SQL statements at the same time, as shown below:
With kbmmwclientquery3 do begin
Query. SQL. Clear;
Query. SQL. Add ('! Insert into T1 (F1, F2) values (100, '20140901 ');
Query. SQL. Add ('! Insert into T1 (F1, F2) values (101, '20140901 ');
End;
After you use kbmmwclienttransactionresolve to submit the request, you will see these two new records inserted in T1.
This method is really good! I think this applies to server-side transaction control, which has not been tested.