4D v14.3Compact data file |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Compact data file
|
Compact data file ( structurePath ; dataPath {; archiveFolder {; option {; method}}} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
structurePath | Text |
![]() |
Pathname of structure file | |||||
dataPath | Text |
![]() |
Pathname of data file to be compacted | |||||
archiveFolder | Text |
![]() |
Pathname of folder where original data file will be put | |||||
option | Longint |
![]() |
Compacting options | |||||
method | Text |
![]() |
Name of 4D callback method | |||||
Function result | Text |
![]() |
Complete pathname of folder containing original data file | |||||
The Compact data file command compacts the data file designated by the dataPath parameter associated with the structurePath structure file. For more information about compacting, refer to the Design Reference manual.
To ensure the continuity of the database operation, the new compacted data file automatically replaces the original file. For security, the original file is not modified and is moved into a special folder named “Replaced files (compacting) YYYY-MM-DD HH-MM-SS” where YYYY-MM-DD HH-MM-SS represents the date and time of the backup. For example: “Replaced files (compacting) 2007-09-27 15-20-35”.
The command returns the complete pathname of the folder actually created to store the original data file. This command can only be executed from 4D (local mode) or 4D Server (stored procedure). The data file to be compacted must correspond to the structure file designated by structurePath. In addition, the data file must not be open when the command is executed; otherwise an error is generated.
If an error occurs during the compacting process, the original files are kept in their initial location. If an index file (.4DIndx file) is associated with the data file, it is also compacted. As with the data file, the original file is saved and the new compacted version replaces the previous one.
Constant | Type | Value | Comment |
Compact address table | Longint | 131072 | Force the address table of the records to be rewritten (slows down compacting). Note that in this case, record numbers are rewritten. If you only pass this option, 4D automatically enables the ’Update records’ option. |
Create process | Longint | 32768 | When this option is passed, compacting will be asynchronous and you will need to manage the results using the callback method (see below). 4D will not display the progress bar (it is possible to do so using the callback method). The OK system variable is set to 1 if the process has been launched correctly and 0 in all other cases. When this option is not passed, the OK variable is set to 1 if the compacting takes place correctly and 0 otherwise. |
Do not create log file | Longint | 16384 | Generally, this command creates a log file in XML format (refer to the end of the command description). With this option, no log file will be created. |
Update records | Longint | 65536 | Force all records to be rewritten according to current definition of the fields in the structure |
By default, the Compact data file command creates a log file in XML format (if you have not passed the Do not create log file option, see the options parameter). Its name is based on that of the data file and it is placed next to this file. For example, for a data file named “data.4dd,” the log file will be named “data_compact_log.xml.”
The following example (Windows) carries out the compacting of a data file:
$structFile:=Structure file
$dataFile:="C:\Databases\Invoices\January\Invoices.4dd"
$origFile:="C:\Databases\Invoices\Archives\January\"
$archFolder:=Compact data file($structFile;$dataFile;$origFile)
If the compacting operation is carried out correctly, the OK system variable is set to 1; otherwise, it is set to 0.
Product: 4D
Theme: 4D Environment
Number:
937
Created: 4D v11 SQL
Modified: 4D v13
Get table fragmentation
VERIFY DATA FILE
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)
Inherited from : Compact data file ( 4D v11 SQL Release 6)