TABLEREVERT( ) Function Example

The following example demonstrates how you can use TABLEREVERT( ) to discard changes made to a buffered table. MULTILOCKS is set to ON, a requirement for table buffering. The customer table in the testdata database is opened, and CURSORSETPROP( ) is then used to set the buffering mode to optimistic table buffering (5).

The value of the cust_id field is displayed and then the cust_id field is modified with REPLACE. The new value of the cust_id field is displayed. TABLEREVERT( ) is then used to return the table to its original state (TABLEUPDATE( ) could be issued instead to commit the changes). The reverted value of the cust_id field is then displayed.

CLOSE DATABASES
SET MULTILOCKS ON  && Must be on for table buffering
SET PATH TO (HOME(2) + 'data\')     && Sets path to database
OPEN DATABASE testdata  && Open testdata database
USE Customer     && Open customer table
= CURSORSETPROP('Buffering', 5, 'customer')  && Enable table buffering

CLEAR
? 'Original cust_id value: '
?? cust_id  && Displays current cust_id value
REPLACE cust_id    WITH '***'  && Changes field contents
? 'New cust_id value: '
?? cust_id  && Displays new cust_id value
= TABLEREVERT(.T.)  && Discard all table changes
? 'Reverted cust_id value: '
?? cust_id  && Displays reverted cust_id value