IRdsNonUniqueKeyAttribute.Attribute

Syntax

Attribute: IRdsAttribute;

Description

The Attribute property determines an MDM dictionary non unique key attribute.

Comments

A non unique key is an additional identifier of records in an MDM dictionary. It is used to set up attribute as alternative hierarchy and to set index to link with alternative hierarchies. A key may consist of a single dictionary attribute which values can repeat for each elements and of several attributes which sum of values is not unique.

Example

Executing the example requires that the repository contains a table MDM dictionary with the ATTRIBUTEN identifier where non unique key with three attributes is added.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Dict: IRdsDictionary;
    UniqueKeys: IRdsNonUniqueKeys;
    UniqueKey: IRdsNonUniqueKey;
    UAttributes: IRdsNonUniqueKeyAttributes;
    UAttribute: IRdsNonUniqueKeyAttribute;
    Attributes: IRdsAttributes;
    Attribute: IRdsAttribute;
    i, j: integer;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get MDM dictionary
    Dict := mb.ItemById("ATTRIBUTEN").Edit As IRdsDictionary;
    
// Get dictionary non unique keys
    UniqueKeys := Dict.NonUniqueKeys;
    
For i := 0 To UniqueKeys.Count - 1 Do
        UniqueKey := UniqueKeys.Item(i);
    
End For;
    
//  Get non unique key attributes
    UAttributes := UniqueKey.Attributes;
    
//  Get dictionary attributes
    Attributes := Dict.Attributes;
    
For i := 0 To Attributes.Count - 1 Do
        Attribute := Attributes.Item(i);
        j := UAttributes.FindByAttribute(Attribute);

        If j >= 0 Then
            UAttribute := UAttributes.Item(j);
        
End If;
    
End For;
    
// Display a list of non unique key attributes to the console window
    Debug.WriteLine("Initial list of non unique key attributes");
    Debug.Indent;
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item(i);
        Debug.WriteLine(UAttribute.Attribute.Id);
    
End For;
    Debug.Unindent;
    
// Move attributes
    UAttributes.Move(1, UAttributes.Count - 1);
    // Display a list of non unique key attributes to the display window
    Debug.WriteLine("List of non unique key attributes after moving");
    Debug.Indent;
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item(i);
        Debug.WriteLine(UAttribute.Attribute.Id);
    
End For;
    
// Save dictionary
    (Dict As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the console window displays list of non unique key attributes before and after moving them. The second and the last attributes of non unique key will be moved.

See also:

IRdsNonUniqueKeyAttribute