Microsoft KB Archive/95250

= How to Recycle Deleted Records in a Multiuser Environment =

Article ID: 95250

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxBASE+ 2.5 for MS-DOS
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxBASE+ 2.1 for Macintosh
 * Microsoft FoxPro 2.5b for Macintosh

-



This article was previously published under Q95250



SUMMARY
The DELETE command does not physically remove a record from the database file. Instead, it places a flag on the record indicating that the record has been deleted. The record can be retrieved by issuing the RECALL command.

The PACK command physically removes deleted records from the file. After the PACK command has been issued, deleted records cannot be recalled. Using PACK requires exclusive use of the file.

In a multiuser environment, it may be difficult to obtain exclusive use of the file for packing. If the file isn't packed, the amount of disk space required to store deleted records will continue to grow. To work around this problem, you can recycle deleted records by using the technique illustrated below.



MORE INFORMATION
The following code snippets blank out all fields in the record when a record is deleted from the file. When an attempt is made to append a new record to the database, the program first checks to see if any blank deleted records are available. If a deleted record is available, the program uses the record to store the new data. If a deleted record is not available, the program appends a blank record.

This code snippet deletes a record in FoxBASE+: DELETE *  Insert code here to replace each field with a blank character, *  date or numeric value. This code snippet deletes a record in FoxPro: IF LOCK SCATTER MEMVAR MEMO BLANK  *  See note below on memo fields. GATHER MEMVAR MEMO         *  MEMO keyword available only DELETE                     *  in FoxPro 2.0. ENDIF The following line must be added to a FoxBASE+ or FoxPro 1.02 program for databases that contain memo fields: REPLACE memofield WITH &quot;&quot; && memofield is the memo field name This code snippet either recycles a deleted record or appends a new blank record in FoxBASE+ and FoxPro: LOCATE FOR DELETED IF EOF APPEND BLANK ELSE RECALL ENDIF Unused space in memo files will not be recycled. To recover unused space in memo files, you must issue a PACK (FoxBASE+) or PACK MEMO (FoxPro) command.

