IRdsUniqueKeys.Add

Fore Syntax

Add: IRdsUniqueKey;

Fore.NET Syntax

Add(): Prognoz.Platform.Interop.Rds.IRdsUniqueKey;

Description

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

Fore 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.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MDMKey: uinteger;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Attrs: IRdsAttributes;
    Attr: IRdsAttribute;
    UniqKeys: IRdsUniqueKeys;
    UniqKey: IRdsUniqueKey;
Begin
    MB := Params.Metabase;
    // Get MDM dictionary
    MDMKey := MB.ItemById["RDS_REPO"].Key;
    MObj := MB.ItemByIdNamespace["MDM_DICT_46586", 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.ddtString;
    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;

See also:

IRdsUniqueKeys