Creates a new index for the table.
procedure AddIndex(const Name,
const DescFields: String='');
Call AddIndex to create a new index for the already-existing table associated with a
dataset component. The index created with this procedure is added to the database table underlying the
Name is the name of the new index. Name must contain an index name that is valid for
Fields is a String value containing the field or fields on which the new index will
be based. If more than one field is used, separate the field names in the list with semi-colons.
Options is a set of attributes for the index. The Options parameter may contain any
one, multiple, or none of the TIndexOptions constants: ixPrimary, xUnique, ixDescending,
ixCaseInsensitive, and ixExpression.
DescFields is a string containing a list of field names, separated by semi-colons. The
fields specified in DescFields are the fields in the new index for which the ordering will be
descending. Fields in the index definition but not in the DescFields list use the default
ascending ordering. It is possible that a single index can have fields using both ascending and
In the example below, the AddIndex method is used to create an index named NewIndex.
This index is based on two fields from the associated table, CustNo and CustName. The
index NewIndex incorporates two index options through the TIndexOptions constants
ixUnique and ixCaseInsensitive.
|Attempting to create an index using options that are not applicable to the table type causes
AddIndex to raise an exception.|