Command(Text: String): IDalCommand;
Text.The MDX query text, with which the object is initialized.
The Command method initializes an object that enables the user to work with server with the MDX queries.
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(Null) As 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.
See also: