IAdoMdCubeExecutor.OpenCellset

Fore syntax

OpenCellset: IAdoMdCellset;

Fore.NET syntax

OpenCellset: Prognoz.Platform.Interop.AdoMd.IAdoMdCellset;

Description

The OpenCellset method returns analytical data obtained after executing a random MDX query to cube.

Fore example

Executing the example requires that the repository contains an ADOMD catalog with the ADOMDTest identifier. The catalog contains the ADOMD cube with the Cube_1 identifier.

Sub UserProc;
Var
    MB: IMetabase;
    CubInst: ICubeInstance;
    CubDest: ICubeInstanceDestination;
    ExeCub: ICubeInstanceDestinationExecutor;
    ExeAdo: IAdoMdCubeExecutor;
    sMDX: String;
    Cellset: IAdoMdCellset;
    AxisInfo: IAdoMdAxisInfo;
    Axis: IAdoMdAxis;
    Dim: IAdoMdAxisDim;
    i, j: Integer;
Begin
    MB := MetabaseClass.Active;
    //Open ADOMD cube
    CubInst := MB.ItemByIdNamespace("Cube_1", MB.GetObjectKeyById("ADOMDTest")).Open(NullAs ICubeInstance;
    CubDest := CubInst.Destinations.DefaultDestination;
    //Create a calculator
    ExeCub := CubDest.CreateExecutor;
    ExeAdo := ExeCub As IAdoMdCubeExecutor;
    //Specify MDX query
    sMDX := "SELECT ...";
    ExeAdo.MdxQuery := sMdx;
    //Get analytical data according to the specified query
    Cellset := ExeAdo.OpenCellset;
    AxisInfo := Cellset.AxisInfo;
    Debug.WriteLine("Axes number: " + AxisInfo.Count.ToString);
    For i := 0 To AxisInfo.Count - 1 Do
        Debug.WriteLine("Axis: " + i.ToString);
        Axis := AxisInfo.Item(i);
        Debug.WriteLine("Dimensions number: " + Axis.DimCount.ToString);
        For j := 0 To Axis.DimCount - 1 Do
            Dim := Axis.Dim(j);
            Debug.Indent;
            Debug.WriteLine("Dimension: " + Dim.Name + "; (Number of attributes: " + Dim.Cols.ToString + ")");
            Debug.WriteLine("Number of elements in dimension:" + Dim.Instance.Elements.Count.ToString);
            Debug.Unindent;
        End For;
    End For;
End Sub UserProc;

On executing the example a multidimensional query is executed for the specified ADOMD cube. The information about the axes, on which the data is formed, is obtained from execution result. Information about all axes is displayed in the development environment console: number and names of dimensions, that are used to form axis coordinates, and number of attributes for each dimension, that describe each coordinate.

Fore.NET example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.AdoMd;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    CubInst: ICubeInstance;
    CubDest: ICubeInstanceDestination;
    ExeCub: ICubeInstanceDestinationExecutor;
    ExeAdo: IAdoMdCubeExecutor;
    sMDX: String;
    Cellset: IAdoMdCellset;
    AxisInfo: IAdoMdAxisInfo;
    Axis: IAdoMdAxis;
    Dim: IAdoMdAxisDim;
    i, j: Integer;
Begin
    MB := Params.Metabase;
    //Open ADOMD cube
    CubInst := MB.ItemByIdNamespace["Cube_1", MB.GetObjectKeyById("ADOMDTest")].Open(NullAs ICubeInstance;
    CubDest := CubInst.Destinations.DefaultDestination;
    //Create a calculator
    ExeCub := CubDest.CreateExecutor();
    ExeAdo := ExeCub As IAdoMdCubeExecutor;
    sMDX := "SELECT...";
    ExeAdo.MdxQuery := sMdx;
    //Get analytical data according to the specified query
    Cellset := ExeAdo.OpenCellset();
    AxisInfo := Cellset.AxisInfo;
    System.Diagnostics.Debug.WriteLine("Axes number: " + AxisInfo.Count.ToString());
    For i := 0 To AxisInfo.Count - 1 Do
        System.Diagnostics.Debug.WriteLine("Axis: " + i.ToString());
        Axis := AxisInfo.Item[i];
        System.Diagnostics.Debug.WriteLine("Dimensions number: " + Axis.DimCount.ToString());
        For j := 0 To Axis.DimCount - 1 Do
            Dim := Axis.Dim[j];
            System.Diagnostics.Debug.Indent();
            System.Diagnostics.Debug.WriteLine("Dimension: " + Dim.Name + "; (Number of attributes: " + Dim.Cols.ToString() + ")");
            System.Diagnostics.Debug.WriteLine("Number of elements in dimension:" + Dim.Instance.Elements.Count.ToString());
            System.Diagnostics.Debug.Unindent();
        End For;
    End For;
End Sub;

See also:

IAdoMdCubeExecutor