TableObject: IMetabaseObjectDescriptor;
The TableObject property determines repository table, from which the data is imported.
Executing the example requires a table with the TBL_IMP identifier. There must also be the MDM repository with the RDS_REPO identifier containing the MDM dictionary with the IMPORT identifier. Identifiers and field types of the TBL_IMP table and of the IMPORT dictionary match.
Add links to the Metabase, Rds, Db system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Import: IRdsImportSchemas;
SchemaImport: IRdsImportSchema;
Attrs: IRdsAttributes;
TableObj: IMetabaseObjectDescriptor;
Table: ITable;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("IMPORT", MB.ItemById("RDS_REPO").Key).Edit;
Dict := MObj As IRdsDictionary;
Attrs := Dict.Attributes;
Import := Dict.ImportSchemas;
SchemaImport := Import.Add;
SchemaImport.Name := Import scheme #1;
SchemaImport.Incremental := True;
SchemaImport.UniqueKey := Dict.UniqueKeys.Item(0);
SchemaImport.Mappings(Attrs.Key).FieldName := "Key";
SchemaImport.Mappings(Attrs.Name).FieldName := "Name";
SchemaImport.Mappings(Attrs.Order).FieldName := "Ord";
SchemaImport.Mappings(Attrs.ParentKey).FieldName := "Parent_key";
TableObj := MB.ItemById("TBL_IMP");
Table := TableObj.Bind As ITable;
SchemaImport.TableObject := TableObj;
SchemaImport.TableName := Table.NativeName;
MObj.Save;
After executing the example a new import scheme is created in the MDM dictionary. Attribute values of the IMPORT dictionary are imported from same-name fields of the TBL_IMP table. The first unique key of the TBL_IMP dictionary is used to check if the imported data is unique. If the unique key is not available, the check is based on the KEY attribute (IRdsAttributes.Key).
See also: