Tech Tip: A utility method to unload the current record from more than one table
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: September 17, 2024
The command UNLOAD RECORD unloads the current record of a table. When records from multiple or all tables must be unloaded simultaneously, writing the command UNLOAD RECORD for each table might not be the best practice.
The following utility method allows one, multiple, or all tables to unload its current record in one line.
// Method: unloadRecord #DECLARE($tableID_c : Collection) var $i : Integer ARRAY LONGINT($tid_al; 0) Begin SQL SELECT TABLE_ID FROM _USER_TABLES INTO :$tid_al; End SQL If ($tableID_c=Null) $tableID_c:=New collection ARRAY TO COLLECTION($tableID_c; $tid_al) End if For each ($tableID_l; $tableID_c) If (Find in array($tid_al; $tableID_l)#-1) UNLOAD RECORD(Table($tableID_l)->) End if End for each |
Example:
// Unload the current record from table ID = 5 unloadRecord([5]) // Unload the current record from table ID = 5 , 9, 10, 11 unloadRecord([5; 9; 10; 11]) // Unload the current record from all tables unloadRecord |