DF_INDEX_KEY_LENGTH
See Also: Get_Attribute, Set_Attribute
The length of the key for the index.
Level
Index
Supported by
All Drivers
Type
Numeric, permanent
Access
Read only
Values
1 ~ maximum length supported in the database
Remarks
Since the value of DF_INDEX_KEY_LENGTH is dependent on how the database stores its data, it may not equal the sum of the values of the DF_FIELD_LENGTH attributes for the fields that make up the index.
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. DataFlex SQL Drivers will return 0 (zero) for every table accessed. Trying to set the attribute will be ignored.
The Embedded Database and DataFlex Pervasive.SQL Driver support this attribute. For the Embedded Database, the attribute can be used to calculate the “real” maximum number of records in a table. See DF_FILE_MAX_RECORDS for a discussion of the “real” maximum.
Define C_MAXINDEXCAPACITY For |CI$00feffff
Function IndexCapacity Integer iKeylength Integer iLevels Returns Integer
Integer iCapacity
Integer iBlocking
Move (1024.0 / (iKeylength + 3)) To iBlocking
Move (((iBlocking ^ iLevels) - 1) Min C_MAXINDEXCAPACITY) To iCapacity
Function_Return iCapacity
End_Function // IndexCapacity
Function RealMaximum Handle hTable Returns Integer
Integer iLastIndex
Integer iIndex
Integer iNumSegments
Integer iKeyLength
Integer iLevels
Integer iIndexCapacity
Integer iTableCapacity
Move 0 To iTableCapacity
Get_Attribute DF_FILE_LAST_INDEX_NUMBER Of hTable To iLastIndex
For iIndex From 1 To iLastIndex
Get_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To iNumSegments
If (iNumSegments > 0) Begin
Get_Attribute DF_INDEX_KEY_LENGTH Of hTable iIndex To iKeyLength
Get_Attribute DF_INDEX_LEVELS Of hTable iIndex To iLevels
Get IndexCapacity iKeyLength iLevels To iIndexCapacity
If (iTableCapacity = 0 Or iTableCapacity > iIndexCapacity) ;
Move iIndexCapacity To iTableCapacity
End
Loop
Function_Return iTableCapacity
End_Function
The sample function above returns the real maximum number of records in an Embedded Database table.