SQL Anywhere expects you to group your commands into transactions. You commit a transaction to make changes to your database permanent. When you alter your data, your alterations are not made permanent right away. Instead, they are recorded in the transaction log and are made permanent when you enter the COMMIT command.
Knowing which commands or actions signify the start or end of a transaction lets you take full advantage of transactions.
Transactions start with one of the following events:
Transactions complete with one of the following events:
For more information about autocommit, see Setting autocommit or manual commit mode.
For more information, see Setting autocommit or manual commit mode, and chained option [compatibility].
Interactive SQL provides you with two options that let you control when and how transactions end:
By default, ODBC operates in autocommit mode. Even if you have set the auto_commit option to Off in Interactive SQL, ODBC's setting will override Interactive SQL's. You can change ODBC's setting using the SQL_ATTR_AUTOCOMMIT connection attribute. ODBC autocommit is independent of the chained option.
SQL Anywhere also supports Transact-SQL commands, such as BEGIN TRANSACTION, for compatibility with Sybase Adaptive Server Enterprise. For more information, see Transact-SQL Compatibility.
For more information, see Transact-SQL Compatibility.
The TransactionStartTime database property returns the time the database was first modified after a COMMIT or ROLLBACK. You can use this property to find the start time of the earliest transaction for all active connections. For example:
BEGIN DECLARE connid int; DECLARE earliest char(50); DECLARE connstart char(50); SET connid=next_connection(null); SET earliest = NULL; lp: LOOP IF connid IS NULL THEN LEAVE lp END IF; SET connstart = CONNECTION_PROPERTY('TransactionStartTime',connid); IF connstart <> '' THEN IF earliest IS NULL OR CAST(connstart AS TIMESTAMP) < CAST(earliest AS TIMESTAMP) THEN SET earliest = connstart; END IF; END IF; SET connid=next_connection(connid); END LOOP; SELECT earliest END |
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |