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;
MObjInst: IMetabaseObjectInstance;
TableInst: IDatasetInstance;
Fields: IDatasetInstanceFields;
Field1, Field2, Field3: IDatasetInstanceField;
Begin
Mb := MetabaseClass.Active;
// Open table
MObjInst := Mb.ItemById("TABLE").Open(Null);
// Cast to the interface that is used to work with table data
TableInst := MObjInst 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 fields 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;
End Sub TableData;
Sub DictionaryData;
Var
Mb: IMetabase;
MObjInst: IMetabaseObjectInstance;
DictInst: IDimInstance;
Elements: IDimElements;
Attribute: IDimAttributeInstance;
i: Integer;
Begin
Mb := MetabaseClass.Active;
// Open dictionary
MObjInst := Mb.ItemById("DICTIONARY").Open(Null);
// Cast to the interface that is used to work with dictionary data
DictInst := MObjInst 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;
MObjInst: IMetabaseObjectInstance;
CubeInst: ICubeInstance;
Destination: ICubeInstanceDestination;
SelSet: IDimSelectionSet;
Matr: IMatrix;
Iter: IMatrixIterator;
Begin
Mb := MetabaseClass.Active;
// Open dictionary
MObjInst := Mb.ItemById("STANDART_CUBE").Open(Null);
// Cast to the interface that is used to work with cube data
CubeInst := MObjInst As ICubeInstance;
Destination := CubeInst.Destinations.DefaultDestination;
// Create and generate selection by which matrix of values will be calculated
SelSet := Destination.CreateDimSelectionSet;
SelSet.FindById("COUNTRY").SelectElement(0, False);
SelSet.FindById("CALENDAR").SelectAll;
// Calculate matrix of values
Matr := Destination.Execute(SelSet);
// Iterator to go through 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: