DF_FILE_RECORD_LENGTH_USED
See Also: Get_Attribute, Set_Attribute, DF_FILE_RECORD_LENGTH
The number of bytes actually used for fields in a physical record in the table.
Level
Table
Supported by
All Drivers
Type
Numeric, permanent
Access
Read Only
Values
0 to value of the DF_FILE_RECORD_LENGTH attribute.
Remarks
The Embedded Database has the ability to declare a physical record length greater than the aggregate length of the fields in the file. The value of the DF_FILE_RECORD_LENGTH_USED attribute is the aggregate length of the fields in the file and may be less than the DF_FILE_RECORD_LENGTH attribute's value.
This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make any sense in some back ends. That is why the Pervasive.SQL and DataFlex SQL Drivers will return the aggregate length of the columns for every table accessed.
Example Procedures
ShowLengthMismatch
Procedure ShowLengthMismatch
Handle hTable
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
Open hTable
Get_Attribute DF_FILE_LOGICAL_NAME Of hTable To sTable
Get_Attribute DF_FILE_RECORD_LENGTH Of hTable To iRecordLength
Get_Attribute DF_FILE_RECORD_LENGTH_USED Of hTable To iRecordLengthUsed
If (iRecordLength <> iRecordLengthUsed) ;
Showln sTable " has a record length mismatch of " (iRecordLength - iRecordLengthUsed) ;
"(" iRecordLength " - " iRecordLengthUsed ") bytes."
Close hTable
End
Until (hTable = 0)
End_Procedure // ShowLengthMismatch
The sample procedure above shows the name of every table in the file list that has a different record length than the aggregate length of all columns.
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.