After creating and setting up objects, fill them with data or get their current data. To get object data, it should be opened, use the IMetabaseObjectDescriptor.Open or IMetabaseObjectDescriptor.OpenWithParam method for it. The methods returns the IMetabaseObjectInstance interface that is common for all opened objects.
When opening various objects, the data term can refer to various entities:
A flat table with values on opening table datasets interfaces.
An element set on opening dictionaries. Each element has a set of values of any attributes.
A values matrix on opening multidimensional data structures. Matrix size is determined by the number of cube dimensions.
A total dataset of source data on opening reports interfaces.
The interfaces that are developed for work with data of various repository objects are described in various assemblies, for example:
Tables, queries, and so on. The Db assembly, the IDatasetInstance interfaces.
Dictionaries and MDM dictionaries. The Dimensions and Rds, assemblies, the IDimInstance and IRdsDictionaryInstance interface.
Cubes. The Cubes, assembly, the ICubeInstance, IAutoCubeInstance, IStandardCubeInstance, ICalculatedCubeInstance interfaces and others.
Time series databases. The Cubes, assembly, the IRubricatorInstance.
Regular reports, express reports, and workbooks. The Report and Express assemblies, the IPrxReport, IEaxAnalyzer interfaces.
For details see the list of available assemblies and their contents.
See the examples of table, dictionary and cube data viewing:
Sub TableData;
Var
Mb: IMetabase;
TableInst: IDatasetInstance;
Fields: IDatasetInstanceFields;
Field1, Field2, Field3: IDatasetInstanceField;
Begin
Mb := MetabaseClass.Active;
// Open table and cast to the interface that is used to work with data
TableInst := Mb.ItemById("TABLE").Open(Null) As IDatasetInstance;
// Get fields
Fields := TableInst.Fields;
Field1 := Fields.FindById("ID");
Field2 := Fields.FindById("NAME");
Field3 := Fields.FindById("VALUE");
// Go through all records and view field values
While Not TableInst.Eof Do
Debug.Write("Identifier: " + Field1.Value);
Debug.Write(". Name: " + Field2.Value);
Debug.WriteLine(". Value: " + Field3.Value);
TableInst.Next;
End While;
TableInst.Close;
End Sub TableData;
Sub DictionaryData;
Var
Mb: IMetabase;
DictInst: IDimInstance;
Elements: IDimElements;
Attribute: IDimAttributeInstance;
i: Integer;
Begin
Mb := MetabaseClass.Active;
// Open dictionary and cast to the interface that is used to work with data
DictInst := Mb.ItemById("DICTIONARY").Open(Null) As IDimInstance;
// Get list of elements
Elements := DictInst.Elements;
// Get the VALUE attribute
Attribute := DictInst.Attributes.FindById("VALUE");
// View attribute values for each dictionary element
For i := 0 To Elements.Count - 1 Do
Debug.Write("Identifier: " + Elements.Id(i));
Debug.Write(". Name: " + Elements.Name(i));
Debug.WriteLine(". Value: " + Elements.AttributeValueO(i, Attribute));
End For;
End Sub DictionaryData;
Sub CubeData;
Var
Mb: IMetabase;
CubeInst: ICubeInstance;
Destination: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
Matr: IMatrix;
Iter: IMatrixIterator;
Begin
Mb := MetabaseClass.Active;
// Open cube and cast to the interface that is used to work with data
CubeInst := Mb.ItemById("STANDART_CUBE").Open(Null) As ICubeInstance;
Destination := CubeInst.Destinations.DefaultDestination;
// Create and form the selection, by which value matrix will be calculated
SelSet := Destination.CreateDimSelectionSet;
SelSet.FindById("COUNTRY").SelectElement(0, False);
SelSet.FindById("CALENDAR").SelectAll;
// Calculate value matrix
Matr := Destination.Execute(SelSet);
// Iterator for going through all obtained values
Iter := Matr.CreateIterator;
Iter.Move(IteratorDirection.First);
While Iter.Valid Do
Debug.Write(Iter.Value + " ");
Iter.Move(IteratorDirection.Next);
End While;
End Sub CubeData;
See also: