[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'BufDataset' (#fcl)

# TCustomBufDataset.AddIndex

Adds an index definition to the dataset

## Declaration

Source position: bufdataset.pas line 641

`public procedure TCustomBufDataset.AddIndex(`
`const AName: string;`
`const AFields: string;`
`AOptions: TIndexOptions;`
`const ADescFields: string = '';`
`const ACaseInsFields: string = ''`
`); virtual;`

## Arguments

`AName` |  | Name which identifies the index
`AFields` |  | Fields included in the index
`AOptions` |  | Options enabled for the index
`ADescFields` |  | List of descending fields
`ACaseInsFields` |  | List of case-insensitive fields

## Description

AddIndex is a procedure used to add an index definition to the dataset. AddIndex calls CheckBiDirectional to ensure that the UniDirectional property contains False. An exception is raised if UniDirectional contains True.

AddIndex checks for a valid value in the AFields argument. An Exception is raised when AFields is an empty string (''). In addition, an index added to an Active dataset cannot cause the index count to exceed the value in MaxIndexesCount. An Exception is raised if the index count would be larger than the value in MaxIndexesCount.

AddIndex creates a TBufDatasetIndex instance by calling InternalAddIndex using the arguments passed to the method. The new index is temporary when the Active property contains True; it will be discarded when the dataset is closed.

## See also

TCustomBufDataset.UniDirectional |  | Indicates if the dataset is for uni-directional navigation only
TDataset.Active |  | Is the dataset open or closed.
TBufDatasetIndex