Insert(Parent: Integer; Data: IRdsDictionaryElementData): Integer;
Insert(Parent: Integer; Data: Prognoz.Platform.Interop.Rds.IRdsDictionaryElementData): Integer;
Parent. Parent element key.
Data. Data of the added element.
The Insert method inserts a new element to the dictionary according to the specified parameters.
The Parent parameter may take a special value:
-2. A new element is inserted into the MDM dictionary root after all elements.
Executing the example requires that the repository contains an MDM repository with the MDM_REPOSITORY identifier containing an MDM dictionary with the MDM_DICTIONARY identifier. This dictionary should have only system attributes.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MDMKey: Integer;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
Data: IRdsDictionaryElementData;
Attr: IRDsAttributes;
Key: Integer;
Begin
MB := MetabaseClass.Active;
// Get MDM repository
MDMKey := MB.ItemById("MDM_REPOSITORY").Key;
// Get MDM dictionary
Dict := MB.ItemByIdNamespace("MDM_DICTIONARY", MDMKey).Bind As IRdsDictionary;
DictInst := Dict.Open(Null);
// Create a new dictionary element
Data := DictInst.CreateElementData;
Attr := Dict.Attributes;
Data.Attribute(Attr.Name.Key) := "New element";
// Insert element to the dictionary
Key := DictInst.Insert(-2, Data);
End Sub UserProc;
After executing the example a new element is added to the MDM dictionary root after all existing elements. The Key variable contains key value of the added element.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MDMKey: uinteger;
Dict: IRdsDictionary;
DictInst: IRdsDictionaryInstance;
Data: IRdsDictionaryElementData;
Attr: IRDsAttributes;
Key: uinteger;
Begin
MB := Params.Metabase;
// Get MDM repository
MDMKey := MB.ItemById["MDM_REPOSITORY"].Key;
// Get MDM dictionary
Dict := MB.ItemByIdNamespace["MDM_DICTIONARY", MDMKey].Bind() As IRdsDictionary;
DictInst := Dict.Open(Null);
// Create a new dictionary element
Data := DictInst.CreateElementData();
Attr := Dict.Attributes;
Data.Attribute[Attr.Name.Key] := "New element";
// Insert element to the dictionary
Key := DictInst.Insert(-2 As uinteger, Data);
End Sub;
See also: