xHarbour Reference Documentation > Command Reference |
Marks one or more records for deletion.
DELETE [<Scope>] [WHILE <lWhileCondition>] [FOR <lForCondition>]
The DELETE command marks one or more records in the current work area for deletion. Records with the deletion flag set become unvisible when SET DELTED is set to ON. Whether or not the deleted flag is set for the current record can be tested with the Deleted() function. The flag marks a record only logically for deletion, it does not remove s record physically from a database file. The logical deletion flag can be removed with the RECALL command.
When a database is open in SHARED mode, the current record must be locked with the RLock() function before DELETE may be called. Failure to do so generates a runtime error. If multiple records should be marked for deletion, the entire file must be locked using FLock(), or the file must be open in EXCLUSIVE mode.
The PACK command removes all records with the deletion flag set physically from a database. The ZAP command removes all records at once, leaving an empty database file.
Note: When the current record is marked for deletion and SET DELETED is ON, the record remains visible until the record pointer is moved.
See also: | DbDelete(), DbEval(), DbRecall(), Deleted(), FLock(), PACK, RECALL, RLock(), SET DELETED, ZAP |
Category: | Database commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the effect of SET DELETED with a record // marked for deletion PROCEDURE Main USE Customer EXCLUSIVE GO TOP ? Deleted() // result; .F. ? Recno() // result: 1 DELETE SET DELETED ON GO TOP ? Deleted() // result; .F. ? Recno() // result: 2 SET DELETED OFF GO TOP ? Deleted() // result; .T. ? Recno() // result: 1 RECALL ? Deleted() // result; .F. CLOSE Customer RETURN
http://www.xHarbour.com