[Reprinted red fish] kbmmw development: kbmmw executes SQL statements in batches in transactions

Source: Internet
Author: User

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.

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.