In code, creating and linking the index object structure together works like this: First, add a new IndexDescriptor object to the dictionary's array of IndexDescriptors. The AddIndex call does this for you. Notice that you also specify in this call wether you want a regular field-based index or a SAI index, by passing in the type of the KeyDescriptor object you want. Note that the KeyDescriptor object is also created for you inside this call.

  Index:= Dict.AddIndex('New_Index', 0, False, 'Text Description', TnxCompKeyDescriptor);

Then (assuming it's a field-based index), using the newly constructed object, we add one or more fields to the index:

  IndexFieldDescriptor :=  TnxCompKeyDescriptor(Index.KeyDescriptor).Add(Dict.GetFieldFromName('IndexedField'));

Member and thus Index Field Options can now be changed from the defaults, if needed:

  IndexFieldDescriptor.IgnoreCase := True;

As mentioned above, using the data dictionary gives you much more flexibility over index creation.    If you don't need the fine control that the data dictionary gives you, you can just use TIndexDefs, TFieldDefs and the CreateTable method of TDataset instead. See the Borland VCL help for description and examples.

Home | Site Contents | Documentation | NexusDB Manual V4 | Delphi Guide | Code Examples & Fragments | How to create Indices?