Export and import schemes are child objects of a MDM dictionary. The Fore language can be used to set up:
Import from the following sources:
Microsoft OLEDB Provider for Oracle.
Microsoft OLEDB Provider for SQL Server.
Microsoft Excel (*.xls, *.xlsx).
Microsoft Access (*.mdb).
Microsoft XML (*.xml).
Text file (*.txt).
Clipboard.
Export to the following consumers:
Microsoft OLEDB Provider for Oracle.
Microsoft OLEDB Provider for SQL Server.
Microsoft Excel (*.xls, *.xlsx).
Microsoft Access (*.mdb).
Microsoft XML (*.xml).
Text file (*.txt).
Executing the example requires that the repository contains an MDM dictionary with the D_EXP_IMP identifier.
The example also requires a form that contains:
The ExpButton button for export.
The ImpButton button for import.
Add links to the Metabase, Rds, Dt system assemblies.
Clicking the ExpButton button exports elements of the D_EXP_IMP dictionary to the text file C:\Data_out.txt. Export options are defined as follows:
Only elements of the first dictionary level are exported.
The exported elements are sorted by value of the NAME attribute.
Clicking the ImpButton button imports data from the text file C:\Data_out.txt to the D_EXP_IMP dictionary.
After executing the example, the D_EXP_IMP dictionary will contain only first level elements after executing export and import.
This procedure is a handler of the Click event for the ExpButton button.
Sub ExpButtonOnClick(Sender: Object; Args: IMouseEventArgs);
Var
Mb: IMetabase;
dictObj: IMetabaseObject;
Dict: IRdsDictionary;
sExport: IMetaRdsExportSchema;
i: Integer;
dictAts: IRdsAttributes;
Attr: IRdsAttribute;
attrMap: IRdsExportSchemaAttribute;
dictSort: IRdsSortAttributes;
dictFilter: IRdsDictionaryFilterConditions;
Cond: IRdsDictionaryFilterCondition;
textCons: IDtTextConsumer;
dictInst: IRdsDictionaryInstance;
Begin
Mb := MetabaseClass.Active;
// Get MDM dictionary
Dict := Mb.ItemById("D_EXP_IMP").Edit As IRdsDictionary;
// Create a new export schema
sExport := Dict.ExportSchemas.Add As IMetaRdsExportSchema;
// Bind dictionary attributes to consumer fields
dictAts := Dict.Attributes;
For i := 0 To dictAts.Count - 1 Do
Attr := dictAts.Item(i);
attrMap := sExport.AddMapping;
attrMap.Attribute := Attr;
attrMap.FieldName := Attr.Id;
End For;
// Specify that consumer must cleared before export
sExport.ClearBeforeExport := True;
// Set sorting by the NAME attribute
dictSort := sExport.SortAttributes;
Attr := dictAts.FindById("NAME");
dictSort.Add(Attr, True);
// Add a filter: only first level elements are exported
dictFilter := sExport.Filter;
Attr := dictAts.FindById("PARENT_KEY");
Cond := dictFilter.Add(Attr);
Cond.Value := Null;
Cond.Operation := RdsConditionOperation.Equal;
// Set up data consumer: text file
textCons := New DtTextConsumer.Create;
textCons.File := "c:\Data_out.txt";
textCons.WriteHeader := True;
textCons.RowDelimiter := #13 + #10;
textCons.DelimitedColumnDelimiter := #9;
textCons.DelimitedTextQualifier := "'";
sExport.Consumer := textCons;
// Save dictionary
(Dict As IMetabaseObject).Save;
// Execute export
dictInst := dictObj.Open(Null) As IRdsDictionaryInstance;
dictInst.ExportData(sExport);
End Sub ExpButtonOnClick;
After executing the example data stored in the text file C:\Data_out.txt is imported to the D_EXP_IMP dictionary.
See also: