DELETE Command

Example   See Also

Marks records for deletion.

Syntax

DELETE
  [Scope] [FOR lExpression1] [WHILE lExpression2]
  [IN nWorkArea | cTableAlias]
  [NOOPTIMIZE]

Arguments

Scope

Specifies a range of records to mark for deletion. The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST.

For more information on scope clauses, see the Scope Clauses topic.

For more information on scope clauses, see the Overview of the Language topic.

The default scope for DELETE is the current record (NEXT 1).

FOR lExpression1

Specifies a condition whereby only the records that satisfy the logical condition lExpression1 are marked for deletion.

Rushmore optimizes a query created with DELETE ... FOR if lExpression1 is an optimizable expression and the table is indexed on DELETED( ). For best performance, use an optimizable expression in the FOR clause.

For information on Rushmore optimizable expressions, see SET OPTIMIZE and "Understanding Rushmore Technology" in Chapter 15, Optimizing Applications, in the Programmer's Guide.

WHILE lExpression2

Specifies a condition whereby records are marked for deletion for as long as lExpression2 evaluates to true (.T.).

IN nWorkArea

Specifies the work area of the table in which records are marked for deletion.

IN cTableAlias

Specifies the alias of the table in which records are marked for deletion.

If you omit nWorkArea and cTableAlias, records are marked for deletion in the table in the currently selected work area.

NOOPTIMIZE

Disables Rushmore optimization of DELETE.

Remarks

Records marked for deletion aren't physically removed from the table until PACK is issued. Records marked for deletion can be recalled (unmarked) with RECALL.