Discards changes made to a buffered row or a buffered table or cursor and restores the OLDVAL(В ) data for remote cursors and the current disk values for local tables and cursors.
Note: |
---|
On a network, the data currently on disk might differ from the data on the disk when the table was opened or the cursor was created. Other users on the network might have changed the data after the table was opened or the cursor was created. |
TABLEREVERT( [lAllRows [, cTableAlias | nWorkArea] ] ) |
Parameters
- lAllRows
-
Determines whether all changes made to the table or cursor are discarded. The following table describes the values for lAllRows.
If row buffering is enabled, Visual FoxPro disregards the value of lAllRows, and changes made to the current record in the table or cursor are discarded.lAllRows Description False (.F.)
If table buffering is enabled, only changes made to the current record in the table or cursor are discarded. (Default)
True (.T.)
If table buffering is enabled, changes made to all records are discarded in the table or cursor.
- cTableAlias
- Specifies the alias of the table or cursor in which the changes are discarded.
- nWorkArea
- Specifies the work area of the table or cursor in which the changes are discarded.
Return Value
Numeric data type. TABLEREVERT(В ) returns the number of records for which changes were discarded.
Remarks
TABLEREVERT(В ) cannot discard changes made to a table or cursor that does not have row or table buffering enabled. If you issue TABLEREVERT(В ) and row or table buffering is not enabled, Visual FoxPro generates an error message. Use CURSORSETPROP(В ) to enable or disable row and table buffering.
Changes are discarded in the table or cursor open in the currently selected work area if TABLEREVERT(В ) is issued without the optional cTableAlias or nWorkArea arguments.
TABLEREVERT(В ) does not return the record pointer to its original position.
TABLEREVERT( ) operates on CursorAdapter objects in the same way as other buffered cursors.
In Visual FoxPro 9.0, you cannot issue the TABLEREVERT(В ) function when a TABLEUPDATE(В ) is in operation.
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.
В | Copy Code |
---|---|
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 |