Home >Web Front-end >H5 Tutorial >html5 Web SQL Database transaction processing function transaction and executeSQL analysis_html5 tutorial skills
1. After creating or opening the database, you can use the transaction API transaction. Each transaction acts as an atomic operation to operate the database and will not be interrupted, thus avoiding data conflicts. The definition of transaction is:
errorCallback: Error callback function. (optional)
successCallback: Execution success callback function. (optional)
2. In the callback function querysql, you can execute SQL statements. The corresponding API function is executeSQL. The definition of executeSQL is:
arguments: The parameters required by the SQL statement are the ones in the sql statement? One-dimensional array arranged sequentially. (optional)
callback: callback function. (optional)
errorCallback: Error callback function. (optional)
Web SQL Database Example
The following uses an example to illustrate the basic usage of Web SQL Database. It first calls openDatabase to create a database named "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: