How to: Enable Buffering
You can enable record and table buffering to protect data during updates.
Enabling Record Buffering
Enable record buffering with the CURSORSETPROP( ) Function.
To enable pessimistic record locking in the current work area
Use this function and value:
CURSORSETPROP("Buffering", 2)
Visual FoxPro attempts to lock the record at the pointer location. If the lock is successful, Visual FoxPro places the record in a buffer and permits editing. When you move the record pointer or use the TABLEUPDATE( ) Function, Visual FoxPro writes the buffered record to the original table.
To enable optimistic record locking in the current work area
Use this function and value:
CURSORSETPROP("Buffering", 3)
Visual FoxPro writes the record at the location of the pointer to a buffer and permits edits. When you move the record pointer or use the TABLEUPDATE( ) Function, Visual FoxPro attempts a lock on the record. If the lock is successful, Visual FoxPro compares the current value of the record on the disk with the original buffer value. If these values are the same, the edits are written to the original table; if these values are different, Visual FoxPro generates an error.
Enabling Table Buffering
Enable table buffering with the CURSORSETPROP( ) function.
To enable pessimistic locking of multiple records in the current work area
Use this function and value:
CURSORSETPROP("Buffering", 4)
Visual FoxPro attempts to lock the record at the pointer location. If the lock is successful, Visual FoxPro places the record in a buffer and permits editing. Use the TABLEUPDATE( ) Function to write the buffered records to the original table.
To enable optimistic locking of multiple records in the current work area
Use this function and value:
CURSORSETPROP("Buffering", 5)
Visual FoxPro writes the records to a buffer and permits edits until you use the TABLEUPDATE( ) Function. Visual FoxPro then performs the following sequence on each record in the buffer:
Attempts a lock on each edited record.
Upon a successful lock, compares the current value of each record on the disk with the original buffer value.
Writes the edits to the original table if the comparison shows the values to be the same.
Generates an error if the values differ.
When table buffering is enabled, Visual FoxPro attempts updates only after using the TABLEUPDATE( ) Function.
See Also
Tasks
How to: Append and Delete Records in Table Buffers