4D v13.4

DELETE SUBRECORD

Home

 
4D v13.4
DELETE SUBRECORD

DELETE SUBRECORD 


 

DELETE SUBRECORD ( subtable ) 
Parameter Type   Description
subtable  Subtable in Subtable from which to delete the current subrecord

Subtables are no longer supported starting with version 11 of 4D. A compatibility mechanism ensures the functioning of this command in converted databases; however, it is strongly recommended to replace any subtables with standard related tables.

DELETE SUBRECORD deletes the current subrecord of subtable. If there is no current subrecord, DELETE SUBRECORD has no effect. After the subrecord is deleted, the current subselection for subtable is empty. As a result, DELETE SUBRECORD can’t be used to scan through a subselection and delete selected subrecords.

The deletion of subrecords is not permanent until the parent record is saved. Deleting a parent record automatically deletes all its subrecords.

To delete a subselection, create the subselection you want to delete, delete the first subrecord, create the subselection again, delete the first subrecord, and so on.

The following example deletes all the subrecords of a subtable:

 ALL SUBRECORDS([People]Children)
 While(Records in subselection([People]Children)>0)
    DELETE SUBRECORD([People]Children)
    ALL SUBRECORDS([People]Children)
 End while

The following example deletes the subrecords in which the age of the child is greater than or equal to 12, from the [People]Children subtable :

 ALL RECORDS([People]` Select all the records
 For($vlRecord;1;Records in selection([People])) ` For all the records in the table
  ` Query all records that have subrecords with the criteria
    QUERY SUBRECORDS([People]Children;[People]Children'Age>=12)
  ` Loop until no subrecords are left by the query
    While(Records in subselection([People]Children)>0)
  ` Delete the subrecord
       DELETE SUBRECORD([People]Children)
  ` Query again
       QUERY SUBRECORDS([People]Children;[People]Children'Age>=12)
    End while
    SAVE RECORD([People]` Save the parent record
    NEXT RECORD([People])
 End for

 
PROPERTIES 

Product: 4D
Theme: Subrecords
Number: 96

This command is deprecated and should not be used anymore

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D v11 SQL

 
SEE ALSO 

ALL SUBRECORDS
QUERY SUBRECORDS
Records in subselection
SAVE RECORD