EPUB | CHM | PDF

TMySQLTable.Properties.IndexName

Top Previous Next

Identifies a secondary index for the table.

Syntax:

property IndexName: String;

Description:

Use IndexName to specify an alternative index for a table. If IndexName is empty, a table's sort order is based on its default index.

If IndexName contains a valid index name, then that index determines the sort order of records.

note IndexFieldNames and IndexName are mutually exclusive. Setting one clears the other.

This example uses the IndexName property to sort the records in a table on the CustNo and OrderNo fields.

MySQLTable1.Active := False;
// Get the current available indexes
MySQLTable1.IndexDefs.Update;
// Find one which combines customer number ('CustNo') and
// order number ('OrderNo')
for I := 0 to MySQLTable1.IndexDefs.Count - 1 do
  if MySQLTable1.IndexDefs.Items[I].Fields = 'CustNo;OrderNo' then
// Set that index as the current index for the table
    MySQLTable1.IndexName := MySQLTable1.IndexDefs.Items[I].Name;
MySQLTable1.Active := True;

note You can control whether to sort data on client-side or on server-side by using ReopenOnIndexChange property.

See also: IndexFieldNames, ReopenOnIndexChange properties