Creating an Index with IndexFieldNames

From RAD Studio
Jump to: navigation, search

Go Up to Sorting Records with Indexes

If there is no defined index that implements the sort order you want, you can create a pseudo-index using the IndexFieldNames property.

Note: IndexName and IndexFieldNames are mutually exclusive. Setting one property clears values set for the other. For information about IndexName, see Specifying an Index with IndexName.

The value of IndexFieldNames is a string. 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. Case-sensitivity of the sort depends on the capabilities of your server. See your server documentation for more information.

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

PhoneTable.IndexFieldNames := 'LastName;FirstName';
PhoneTable->IndexFieldNames = "LastName;FirstName";

Note: If you use IndexFieldNames on Paradox and dBASE tables, the dataset attempts to find an index that uses the columns you specify. If it cannot find such an index, it raises an exception.

See Also