In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to use the transaction function transaction and executeSQL. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Comments: an example is given to illustrate the basic use of Web SQL Database. It first calls openDatabase to create a database called "fooDB". Then use transaction to execute two SQL statements. The first SQL statement creates a table named "foo", and the second SQL statement inserts a record into the table
1. After you create or open the database, you can use the transaction API transaction. Each transaction, as an atomic operation that operates the database, is not interrupted, thus avoiding data conflicts. Transaction is defined as:
The code is as follows:
Void transaction (querysql, errorCallback, successCallback)
Querysql: the transaction callback function, where the SQL statement can be executed. (required)
ErrorCallback: error callback function. (optional)
SuccessCallback: execute the callback function successfully. (optional)
2. In the callback function querysql, you can execute the SQL statement. The corresponding API function is defined as executeSQL,executeSQL:
The code is as follows:
Void executeSql (sqlStatement, arguments, callback, errorCallback)
SqlStatement:SQL statement. (required)
The parameters required by the arguments:SQL statement are those in the sql statement. An one-dimensional array arranged sequentially. (optional)
Callback: callback function. (optional)
ErrorCallback: error callback function. (optional)
Web SQL Database example
Here is an example to illustrate the basic use of Web SQL Database. It first calls openDatabase to create a database called "fooDB". Then use transaction to execute two SQL statements. The first SQL statement creates a table named "foo", and the second SQL statement inserts a record into the table.
Sample code:
Var db = openDatabase ('fooDB',' 1.0, 'fooDB', 2 * 1024)
Db.transaction (function (tx) {
Tx.executeSql ('CREATE TABLE IF NOT EXISTS foo (id unique, text)')
Tx.executeSql ('INSERT INTO foo (id, text) VALUES (1, "foobar"))
});
These are all the contents of the article "how to use transaction functions transaction and executeSQL". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.