DF_FILE_RECORD_LENGTH
See Also: Get_Attribute, Set_Attribute, DF_FILE_RECORD_LENGTH_USED
The length, in bytes, of a physical record in the table.
Level
Table
Supported by
All Drivers
Type
Numeric, permanent
Access
Read / Write
Values
- 0 ~ maximum number of bytes allowed in a record of the database system
Remarks
The physical record length of a table refers to the amount of space allocated on disk for records in the table.
This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make sense in some back ends. The Pervasive.SQL and DataFlex SQL Drivers will return the aggregate length of the columns for every table accessed, and attempts to set the attribute will be ignored.
In the Embedded Database, the physical record length may not represent the aggregate length of the columns in the table, although it will always be at least that large.
When columns are added to or changed in a database table in a way that increases record length, the Embedded Database driver will automatically increase the record length as needed. If you are changing a table definition so that columns are removed or reduced in size, you may want to decrease the record length, as it is not automatically adjusted. Doing so may improve many database operations, such as rereading records from disk and reindexing the table.
This attribute can only be set inside a Structure_Start ... Structure_End operation. You may want to set this attribute directly if you wish to use fixed record lengths. In that case, if you add new fields or increase existing fields and they fit into the existing record length, restructuring should be somewhat faster. The record length for an Embedded Database table can be:
- At least 8 bytes
- Any value between 8 and 256
- Above 256, record lengths are incremented in multiples of 128 bytes
If the record length is set to a non-supported value, the value is automatically corrected.
Example Procedures
ShowRecordLength
Procedure ShowRecordLength
Handle hTable
String sTable
Integer iRecordLength
Move 0 To hTable
Repeat
Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
If (hTable > 0) Begin
Open hTable
Get_Attribute DF_FILE_LOGICAL_NAME Of hTable To sTable
Get_Attribute DF_FILE_RECORD_LENGTH Of hTable To iRecordLength
Showln sTable " -- " iRecordLength
Close hTable
End
Until (hTable = 0)
End_Procedure // ShowRecordLength
The sample procedure above shows the record length of every table in the file list.
FixupLengthMismatch
Procedure FixupLengthMismatch
Handle hTable
Handle hStruct
String sTable
Integer iRecordLength
Integer iRecordLengthUsed
Move 0 To hTable
Repeat
Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
If (hTable > 0) Begin
//*** Cannot open flexerrs exclusive!
Get_Attribute DF_FILE_ROOT_NAME Of hTable To sTable
If (Uppercase(sTable) <> "FLEXERRS") Begin
Open hTable Mode DF_EXCLUSIVE
Get_Attribute DF_FILE_RECORD_LENGTH Of hTable To iRecordLength
Get_Attribute DF_FILE_RECORD_LENGTH_USED Of hTable To iRecordLengthUsed
If (iRecordLength - iRecordLengthUsed > 128) Begin
Move hTable To hStruct
Structure_Start hStruct
Set_Attribute DF_FILE_RECORD_LENGTH Of hStruct To iRecordLengthUsed
Structure_End hStruct
End
Close hTable
End
End
Until (hTable = 0)
End_Procedure // FixupLengthMismatch
The sample procedure above adjusts the record length of tables that have a mismatch between the record length and the aggregate length of the columns greater than 128 bytes.