Cancels any changes made during the current transaction.
ROLLBACK restores the original tables, table memo files, and index files to the state they were in before the transaction began.
When you modify records in a database that is part of a transaction, other users on the network do not have access (read or write) to the records until you end the transaction.
When other users on the network try to access records you have modified, they must wait until you end your transaction. They receive the message "Record not available ... please wait" until the records become available. Because of this, it is important to keep the length of the transaction to a minimum or conduct the transaction during times when others do not need access.
ROLLBACK undoes any changes made during the current transaction. If the transaction is nested, only the modifications made since the previous BEGIN TRANSACTION are undone. Program execution continues with the next statement.
If any record or file locks were placed, they are released.
In the following example, the customer table in the testdata database is opened. Optimistic table buffering is set for the customer table. The contents of the
company fields are displayed, and then the contents of the
company field are replaced within the buffered data.
BEGIN TRANSACTION is issued to start a transaction. A TABLEUPDATE is used to write the changes to the table. The new contents are displayed, and ROLLBACK is issued to restore the original contents of the
company field. The
company fields are displayed again with the
company field containing its original values.
CLOSE DATABASES CLEAR * Transactions are only supported within a DBC OPEN DATABASE (HOME(2) + 'Data\testdata') SET MULTILOCKS ON && Required for buffering USE customer =CURSORSETPROP("Buffering",5) ? 'The original company field' LIST FIELDS cust_id, company NEXT 5 REPLACE ALL company WITH "***" && Change field contents BEGIN TRANSACTION =TABLEUPDATE(.T.) GO TOP ? 'The modified company field' LIST FIELDS cust_id, company NEXT 5 ROLLBACK && Restore original field contents =TABLEREVERT(.T.) GO TOP ? 'The restored company field' LIST FIELDS cust_id, company NEXT 5