AutoCommit controls whether PocketBuilder issues SQL statements outside or inside the scope of a transaction.
When AutoCommit is set to false (the default), PocketBuilder issues SQL statements inside the scope of a transaction. When AutoCommit is set to true, PocketBuilder issues SQL statements outside the scope of a transaction.
When to specify AutoCommit
In the development environment, you must
set AutoCommit before connecting to the database using ODBC. AutoCommit
takes effect only when the database connection occurs. Changes made
to AutoCommit after the connection occurs have no effect on the
current connection.
When you connect to an UltraLite database in the development environment, all processing in painters takes place as if AutoCommit is set to true. The setting in the database profile applies when you run or debug an application.
In a PocketBuilder application script, you can reset the value of AutoCommit at any time. This lets you override the initial setting if necessary.
You can set AutoCommit in a script as a property of the Transaction object. The following syntax assumes you are using the default Transaction object SQLCA, but you can also define your own Transaction object:
SQLCA.AutoCommit = value
Parameter |
Description |
---|---|
value |
Specifies whether PocketBuilder issues SQL statements outside or inside the scope of a transaction. Values are:
|
Select or clear the AutoCommit Mode check box on the Connection tab in the Database Profile Setup dialog box, as follows:
Select the check box Sets AutoCommit to true for this connection.
Clear the check box (Default) Sets AutoCommit to false for this connection.
AutoCommit = false
Transactions A transaction is one or more SQL statements that form a logical unit of work (LUW). Within a transaction, all SQL statements must succeed or fail as one logical entity. Changes are made to the database only if all statements in the transaction succeed and a COMMIT is issued. If one or more statements fail, you must issue a ROLLBACK to undo the changes. This ensures the integrity and security of data in your database.
When you change the value of AutoCommit from false to true, PocketBuilder issues a COMMIT statement by default.
Caution
When you set AutoCommit to true, you cannot roll back database
changes. Therefore, use care when changing the setting of AutoCommit.
Using EXECUTE IMMEDIATE When AutoCommit is set to true, you can use the EXECUTE IMMEDIATE dynamic SQL statement to issue BEGIN TRANSACTION, COMMIT TRANSACTION, ROLLBACK TRANSACTION, and other SQL statements to control your own transaction processing.
If you use the EXECUTE IMMEDIATE dynamic SQL statement to issue BEGIN TRANSACTION, you must use the EXECUTE IMMEDIATE dynamic SQL statement to issue a corresponding COMMIT TRANSACTION or ROLLBACK TRANSACTION.
For information about using the EXECUTE IMMEDIATE statement, see the PowerScript Reference.
To set AutoCommit to true and issue SQL statements outside the scope of a transaction:
Development environment Select the AutoCommit Mode check box on the Connection tab in the Database Profile Setup dialog box.
PocketBuilder application script Type the following in a script:
SQLCA.AutoCommit = true
If you specify AutoCommit Mode in your database profile, the PowerScript syntax displays on the Preview tab in the Database Profile Setup dialog box. You can copy the syntax from the Preview tab into your script.