CreateQuery(Value: IMatrix): IMatrixQuery;
CreateQuery(Value: Prognoz.Platform.Interop.Matrix.IMatrix): Prognoz.Platform.Interop.Matrix.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, Cubes, ForeSystem, ForeCollections 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;
Executing the example requires a time series database with the CUBE identifier.
Add links to the Metabase, Matrix, Dimensions, Cubes, ForeSystem, ForeCollections system assemblies.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.ForeCollections;
Sub Main(Params: StartParams);
Var
Mb: IMetabase;
ObjDes: IMetabaseObjectDescriptor;
CubDest: ICubeInstanceDestination;
Sels, SelsAll: IDimSelectionSet;
sDim: String;
Ei: Uinteger;
Sel: IDimSelection;
Matrix, MatrixRes: IMatrix;
MatFac: IMatrixModelFactory;
Query: IMatrixQuery;
Filter: IMatrixQueryFilter;
ArList: IArrayList;
Result: IMatrixQueryResult;
Ranges: IMatrixQueryFilterRanges;
Range: IMatrixQueryFilterRange;
Begin
Mb := Params.Metabase;
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,1);
//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 the first data filtering range
Range := Ranges.Add();
Range.Max := 10000000;
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
System.Diagnostics.Debug.WriteLine(ArList.Count);
//check whether we received the required matrix
If Matrix = Query.Matrix Then
System.Diagnostics.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;
End Class;
See also: