Function DbDelete() Foundation

Marks record as deleted.

Syntax
DbDelete() --> NIL
Return

The return value of DbDelete() is always NIL.

Description

The database function DbDelete() marks the current record in a work area as "deleted". When the function is used without the alias operator, the current record in the current work area is marked as "deleted". DbDelete() logically deletes records but does not physically remove them from the database file. The deletion flag is displayed as an asterisk (*) in the output of commands like LIST and DISPLAY.

The visibility of records marked as "deleted" is set using the command SET DELETED ON | OFF. If SET DELETED is set to ON and the current record is marked as deleted, it remains visible until the record pointer is moved. records marked as deleted are "undeleted" with the function DbRecall(). The command PACK actually removes all data records marked as "deleted" from a file. The command ZAP is used to delete and physically remove all records from a file.

The command DELETE can be used instead of DbDelete(). DELETE is effective only in the current work area.

When multi-user access to the file is allowed, a record must be locked with RLock() before the function DbDelete() is called.

Examples
Logical deletion of records

// The example shows that DbDelete() causes only a logical 
// deletion of records. 

PROCEDURE Main 
   USE Customer NEW EXCLUSIVE 
   INDEX ON Name TO CustA 
   SET INDEX TO CustA 

   GO TOP 
   ? Customer->Name             // result: Anderson 
   ? Customer->( LastRec() )    // result: 100 
   ? Customer->( Deleted() )    // result: .F. 

   Customer->( DbDelete() )     // set deletion flag 

   ? Customer->Name             // result: Anderson 
   ? Customer->( LastRec() )    // result: 100 
   ? Customer->( Deleted() )    // result: .T. 

   SET DELETED ON               // filter out records 
                                // with deletion flags 
   GO TOP 
   ? Customer->Name             // result: Brown 
   ? Customer->( LastRec() )    // result: 100 
   ? Customer->( Deleted() )    // result: .F. 

   PACK                         // physically delete records 
                                // with deletion flags 

   SET DELETED OFF 
   GO TOP 
   ? Customer->Name             // result: Brown 
   ? Customer->( LastRec() )    // result:  99 
   ? Customer->( Deleted() )    // result: .F. 

   CLOSE Customer 
RETURN 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.