IRdsUniqueKeys.Add

Syntax

Add: IRdsUniqueKey;

Description

The Add method creates a new unique key of the MDM dictionary.

Example

Executing the example requires that the repository contains an MDM repository with the MDM identifier containing an MDM dictionary with the MDM_DICT identifier.

Add links to the Dal, Metabase and Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MDMKey: Integer;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Attrs: IRdsAttributes;
    Attr: IRdsAttribute;
    UniqKeys: IRdsUniqueKeys;
    UniqKey: IRdsUniqueKey;
Begin
    MB := MetabaseClass.Active;
    // Get MDM dictionary
    MDMKey := MB.ItemById("RDS_REPO").Key;
    MObj := MB.ItemByIdNamespace("MDM_DICT", MDMKey).Edit;
    Dict := MObj As IRdsDictionary;
    // Get dictionary attributes
    Attrs := Dict.Attributes;
    // Get collection of unique keys
    UniqKeys := Dict.UniqueKeys;
    // Create dictionary attribute
    Attr := Attrs.Add;
    Attr.DataType := DbDataType.String;
    Attr.Id := "ITN";
    Attr.Name := "Personal Tax Reference Number";
    // Create unique key based on the created attribute
    UniqKey := UniqKeys.Add;
    UniqKey.Id := "UNIKKEY_ITN";
    UniqKey.Name := "Unique key based on Personal Tax Reference Number";
    UniqKey.Contains(Attr) := True;
    // Save changes
    MObj.Save;
End Sub UserProc;

After executing the example a custom attribute is created in the MDM dictionary. A unique key of the MDM dictionary is created by this attribute.

See also:

IRdsUniqueKeys