DELETE SELECTION

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 3


DELETE SELECTION {(table)}

ParameterTypeDescription
tableTableTable for which to delete the current selection, or
Default table, if omitted

Description

DELETE SELECTION deletes the current selection of records from table. If the current selection is empty, DELETE SELECTION has no effect. After the records are deleted, the current selection is empty. Records that are deleted during a transaction are locked to other users and other processes until the transaction is validated or canceled.

Warning: Deleting a selection of records is a permanent operation, and cannot be undone.

The Completely Delete option in the Table Properties dialog box allows you to increase the speed of deletions when DELETE SELECTION is used.

Examples

1. The following example displays all the records from the [People] table and allows the user to select which ones to delete. The example has two sections. The first is a method to display the records. The second is an object method for a Delete button. Here is the first method:

   ALL RECORDS ([People])  ` Select all records 
   OUTPUT FORM ([People]; "Listing") ` Set the form to list the records 
   DISPLAY SELECTION ([People])  ` Display all records

The following is the object method for the Delete button, which appears in the Footer area of the output form. The object method uses the records the user selected (the UserSet) to delete the selection. Note that if the user did not select any records, DELETE SELECTION has no effect.

      ` Confirm that the user really wants to delete the records
   CONFIRM("You selected "+String(Records in set ("UserSet"))+" people to delete."
                                    +Char(13)+"Click OK to Delete them.")
   If (OK=1)
      USE SET ("UserSet") ` Use the records chosen by the user
      DELETE SELECTION([People]) ` Delete the selection of records
   End if
   ALL RECORDS ([People]) ` Select all records

2. If a locked record is encountered during the execution of DELETE SELECTION, that record is not deleted. Any locked records are put into a set called LockedSet. After DELETE SELECTION has executed, you can test the LockedSet to see if any records were locked. The following loop will execute until all the records have been deleted:

   Repeat  ` Repeat for any locked records
      DELETE SELECTION([ThisTable])
      If (Records in set("LockedSet")#0) ` If there are locked records
         USE SET ("LockedSet") ` Select only the locked records
      End if
   Until (Records in set("LockedSet")=0) ` Until there are no more locked records

See Also

DISPLAY SELECTION, MODIFY SELECTION, Record Locking, Sets.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next