Specifying fields with IndexFieldNames

From InterBase

Go Up to Working with Tables


IndexFieldNames is a string list property. To specify a sort order, list each column name to use in the order it should be used, and delimit the names with semicolons. Sorting is by ascending order only.

The following code sets the sort order for PhoneTable based on LastName, then FirstName:

PhoneTable.IndexFieldNames := 'LastName;FirstName';

Examining the field list for an index

When your application uses an index at runtime, it can examine the

  • IndexFieldCount property, to determine the number of columns in the index.
  • IndexFields property, to examine a list of column names that comprise the index.

IndexFields is a string list containing the column names for the index. The following code fragment illustrates how you might use IndexFieldCount and IndexFields to iterate through a list of column names in an application:

var
  I: Integer;
  ListOfIndexFields: array[0 to 20} of string;
begin
with CustomersTable do
  begin
  for I := 0 to IndexFieldCount - 1 do
     ListOfIndexFields[I] := IndexFields[I];
  end;
end;
Note:
IndexFieldCount is not valid for a base table opened on an expression index.

Advance To: