CreateQuery(Value: IMatrix): IMatrixQuery;
Value. Matrix, for which a query is created.
The CreateQuery method creates a query that is used to get information about existing data in the specified matrix.
Executing the example requires a time series database with the CUBE identifier.
Add links to the Metabase, Matrix, Dimensions, and Cubes system assemblies.
Sub Main;
Var
Mb: IMetabase;
ObjDes: IMetabaseObjectDescriptor;
CubDest: ICubeInstanceDestination;
Sels, SelsAll: IDimSelectionSet;
sDim: String;
Ei: Integer;
Sel: IDimSelection;
Matrix, MatrixRes: IMatrix;
MatFac: MatrixFactory;
Query: IMatrixQuery;
Filter: IMatrixQueryFilter;
ArList: IArrayList;
Result: IMatrixQueryResult;
Ranges: IMatrixQueryFilterRanges;
Range: IMatrixQueryFilterRange;
Begin
Mb := MetabaseClass.Active;
ObjDes := Mb.ItemById("CUBE");
CubDest := (ObjDes.Open(Null) As ICubeInstance).Destinations.DefaultDestination;
Sels := CubDest.CreateDimSelectionSet;
For Each Sel In Sels Do
sDim := Sel.Dimension.Name;
If sDim = "Calendar" Then
For Ei:=10 To 50 Do
Sel.SelectElement(Ei, False);
End For;
Else
Sel.SelectAll;
End If;
End For;
SelsAll := Sels;
Matrix := CubDest.Execute(SelsAll);
//create query used to get information about existing data in the specified matrix
MatFac := New MatrixFactory.Create;
Query := (MatFac As IMatrixFactory).CreateQuery(Matrix);
//set up filtering parameters for matrix data
Filter := Query.Filter;
//get collection of filtering ranges for matrix data
Ranges := Filter.Ranges;
//add a data filtering range
Range := Ranges.Add;
Range.Max := 10;
Range.Min := 0;
//determine selection of dictionaries collection for matrix query
Filter.Selection := Sels;
//get a dynamic array of filter elements
ArList := Filter.Values;
//get number of elements in the array
debug.WriteLine(ArList.Count);
//check whether we received the required matrix
If Matrix = Query.Matrix Then
debug.WriteLine("Matrices match");
End If;
//determine parameters of matrix iterator
Query.Select_;
//perform query
Query.Execute;
//get query results
Result := Query.Result;
//result of query as a matrix
MatrixRes := Result.Matrix;
End Sub Main;
See also: