BeforeConstruction(Components: ISQLComponents);
Components. The list of separate parts of query that can be modified.
The BeforeConstruction method is called before generating a query to extract cube data.
The method must be redefined in a user class. Using the Components parameters it is possible to get separate parts of query and modify it if required.
The specified class is a handler of query generation for cube data extraction. The class should be saved to the unit and assign it as a handler to cube data source using the IStandardCubeDataset.SetCallback method.
Public Class SQLCallback: Object, ISQLCallback
Sub BeforeConstruction(Components: ISQLComponents);
Var
i: Integer;
Select_, From_, Where, GroupBy, Aggregation, OrderBy: String;
Begin
Debug.WriteLine("Select_: " + Components.Select_);
Debug.WriteLine("From_: " + Components.From_);
Debug.WriteLine("Where: " + Components.Where);
Debug.WriteLine("GroupBy: " + Components.GroupBy);
Debug.WriteLine("Aggregation: " + Components.Aggregation);
Debug.WriteLine("OrderBy: " + Components.OrderBy);
Debug.WriteLine("SubQuery: " + Components.SubQuery.ToString);
Debug.WriteLine("ConditionCount: " + Components.ConditionCount.ToString);
For i := 0 To Components.ConditionCount - 1 Do
Debug.WriteLine("Condition " + i.ToString + " : " + Components.Condition(i).Condition);
End For;
Debug.WriteLine("TableAlias: " + Components.TableAlias);
//---Modified parts of query
//Select_ := Components.Select_;
//...
//Modification of Select_
//...
//Components.Select_ := Select_;
//From_ := Components.From_;
//...
//Modification of From_
//...
//Components.From_ := From_;
//Where := Components.Where;
//...
//Modification of Where
//...
//Components.Where := Where;
//GroupBy := Components.GroupBy;
//...
//Modification of GroupBy
//...
//Components.GroupBy := GroupBy;
//Aggregation := Components.Aggregation;
//...
//Modification of Aggregation
//...
//Components.Aggregation := Aggregation;
//OrderBy := Components.OrderBy;
//...
//Modification of OrderBy
//...
//Components.OrderBy := OrderBy;
End Sub BeforeConstruction;
Sub AfterConstruction(Var SQL: String);
Begin
//If required, modification of final query text in SQL variable
Debug.WriteLine("AFTER: " + SQL);
End Sub AfterConstruction;
End Class SQLCallback;
On executing the cube, the BeforeConstruction procedure will be launched first, on its execution all parts of generated report will be displayed into development environment console. If required, any block can be uncommented and a part of query can be modified. Fully generated query will be displayed on executing the AfterConstruction method.
See also: