ITableIndex.Primary

Syntax

Primary: Boolean;

Description

The Primary property determines whether an index is primary.

Comments

The indicator of uniqueness is automatically set for the primary index. The primary key is created by fields that do not take empty values. On adding the fields into the collection of the primary index, this indicator is automatically set for them.

Example

Executing the example requires that the repository contains a table with the Table_1 identifier. The table contains at least two fields.

Sub Main;

Var

MB: IMetabase;

Table: ITable;

Fields: ITableFields;

Index: ITableIndex;

Begin

MB := MetabaseClass.Active;

Table := MB.ItemById("Table_1").Edit As ITable;

Fields := Table.Fields;

Index := Table.Indexes.Add;

Index.Fields.Add(Fields.Item(0));

Index.Fields.Add(Fields.Item(1));

Index.Primary := True;

(Table As IMetabaseObject).Save;

End Sub Main;

After executing the example, the primary index is created in the table. This index is created by two first fields of the table.

See also:

ITableIndex