BEGIN TRANSACTION Command Example
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 cust_id
and company
fields are displayed, and then the contents of the company
field is replaced within the buffered data.
BEGIN TRANSACTION is issued to start a transaction. The TABLEUPDATE( ) function 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 cust_id
and company
fields are displayed again with the company
field containing its original values.
CLEAR
CLOSE DATABASES
* 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