IAdoMdConnection.Command

Fore Syntax

Command(Text: String): IDalCommand;

Fore.NET Syntax

Command(Text: string): Prognoz.Platform.Interop.Dal.IDalCommand;

Parameters

Text.The MDX query text, with which the object is initialized.

Description

The Command method initializes an object that enables the user to work with server with the MDX queries.

Fore Example

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

Sub UserProc;
Var
    MB: IMetabase;
    Catalog: IAdoMdCatalogInstance;
    Connection: IAdoMdConnection;
    sMDX: String;
    Command: IDalCommand;
    ResultCursor: IDalCursor;
    CFields: IDalCursorFields;
    CField: IDalCursorField;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    Catalog := MB.ItemById("ADOMDTest").Open(NullAs IAdoMdCatalogInstance;
    Connection := Catalog.Connection;
    sMDX := "SELECT ...";
    Command := Connection.Command(sMDX);
    //MDX query execution
    Command.Execute;
    //Obtaining execution results
    ResultCursor := Command.CreateCursor;
    CFields := ResultCursor.Fields;
    While Not ResultCursor.Eof Do
        For i := 0 To CFields.Count - 1 Do
            CField := CFields.Item(i);
            Debug.WriteLine(CField.Name + " | " + CField.Value);
        End For;
        ResultCursor.Next;
    End While;
End Sub UserProc;

The command, used to execute multidimensional queries, is created on executing the example. The cursor, containing the result, is created after the query execution. The results are displayed in the development environment console.

Fore.NET Example

Executing the example requires that the repository contains an ADOMD catalog with the ADOMDTest identifier. This example is an entry point of the .NET assembly.

Imports Prognoz.Platform.Interop.AdoMd;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Metabase;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Catalog: IAdoMdCatalogInstance;
    Connection: IAdoMdConnection;
    sMDX: String;
    Command: IDalCommand;
    ResultCursor: IDalCursor;
    CFields: IDalCursorFields;
    CField: IDalCursorField;
    i: Integer;
Begin
    MB := Params.Metabase;
    Catalog := MB.ItemById["ADOMDTest"].Open(NullAs IAdoMdCatalogInstance;
    Connection := Catalog.Connection;
    sMDX := "SELECT ...";
    Command := Connection.Command(sMDX);
    //MDX query execution
    Command.Execute();
    //Get execution results
    ResultCursor := Command.CreateCursor();
    CFields := ResultCursor.Fields;
    While Not ResultCursor.Eof() Do
        For i := 0 To CFields.Count - 1 Do
            CField := CFields.Item[i];
            System.Diagnostics.Debug.WriteLine(CField.Name + " | " + CField.Value);
        End For;
        ResultCursor.Next();
    End While;
End Sub;

The command, used to execute multidimensional queries, is created on executing the example. The cursor, containing the result, is created after the query execution. The results are displayed in the development environment console.

See also:

IAdoMdConnection