DELETE - SQL Command Example

The following example opens the customer table in the testdata database. DELETE - SQL is used to mark all records for deletion where the country field contains USA. All the records marked for deletion are displayed. RECALL ALL is used to unmark all the records marked for deletion.

CLOSE DATABASES
CLEAR

OPEN DATABASE HOME(2)+"Data\testdata"
USE customer  && Open Customer table

DELETE FROM customer WHERE country = "USA"   && Mark for deletion

CLEAR
LIST FIELDS company, country FOR DELETED( )  && List marked records
* If the file were packed at this point the records would be deleted
WAIT WINDOW "Records currently marked for deletion"+CHR(13) + ;
   "Press any key to revert..."

* Unmark all records marked for deletion
RECALL ALL
CLEAR
* Verify reverted records
COUNT FOR DELETED( )=.T. TO nDeleted

* Convert nDeleted to a character string and display information
WAIT WINDOW ALLTRIM(STR(nDeleted)) + " records marked for deletion."