Quickly Define Powerful Client-Side Aggregating Formulas With FireDAC Using TFDQuery In Delphi
January 24, 2021 by Konstantin Tomov
This sample demonstrates how to define the client-side aggregating formulas with Для просмотра ссылки Войдиили Зарегистрируйся. You can find out more about Для просмотра ссылки Войди или Зарегистрируйся in the Embarcadero DocWiki.
The fkAggregate aggregated fields management is similar to the expression calculated fields management. FireDAC calculates aggregated fields when Для просмотра ссылки Войдиили Зарегистрируйся is set to True (by default, its value is set to False). The aggregated expression cannot be changed when the dataset is active. Also, the FireDAC application can use the Для просмотра ссылки Войди или Зарегистрируйся collection to define aggregated values. They are more light-weighted than fields and can be defined at any time, including when the dataset is active.
или Зарегистрируйся as follows:
или Зарегистрируйся. When you select an item of the combo box, the sample uses the Для просмотра ссылки Войди или Зарегистрируйся method of qryAggregates in order to execute the SQL statement that retrieves the “Orders” table from the database. Then, the sample displays the “Orders” table using a Для просмотра ссылки Войди или Зарегистрируйся component. Once the DBGrid1 is filled, you can interact with the sample in the following ways:
Для просмотра ссылки Войдиили Зарегистрируйся
Для просмотра ссылки Войдиили Зарегистрируйся
January 24, 2021 by Konstantin Tomov
This sample demonstrates how to define the client-side aggregating formulas with Для просмотра ссылки Войди
The fkAggregate aggregated fields management is similar to the expression calculated fields management. FireDAC calculates aggregated fields when Для просмотра ссылки Войди
Location
You can find the Aggregates sample project at:- Start | Programs | Embarcadero RAD Studio Sydney | Samplesand then navigate to:
- Object PascalDatabaseFireDACSamplesComp LayerTFDQueryAggregates
- Subversion Repository:
- You can find Delphi code samples in Для просмотра ссылки Войди
или Зарегистрируйся. Search by name into the samples repositories according to your RAD Studio version.
- You can find Delphi code samples in Для просмотра ссылки Войди
How to Use the Sample
- Navigate to the location given above and open Aggregates.dproj.
- Press F9 or choose Run > Run.
Files
File in Delphi | Contains |
---|---|
Aggregates.dproj Aggregates.dpr | The project itself. |
fAggregates.pas fAggregates.fmx | The main form. |
Implementation
Before running the sample, the main components are configured at design time using the Для просмотра ссылки Войди- A Для просмотра ссылки Войди
или Зарегистрируйся object named qryAggregates. This component is used to implement a dataset capable of executing SQL queries. The following setup is needed: - Configure the Для просмотра ссылки Войди
или Зарегистрируйся property to specify the FireDAC connection object that is used to connect to a DBMS. - Set the Для просмотра ссылки Войди
или Зарегистрируйся property to select * from {id Orders}. It specifies the SQL statement to execute for the query. - Edit the Для просмотра ссылки Войди
или Зарегистрируйсяproperty with 4 aggregate expressions:- AVG(Freight)
- SUM(Freight)
- MAX(OrderID)
- Typed by the user using the edit box.
- A Для просмотра ссылки Войди
или Зарегистрируйся object named DataSource1. This component provides an interface between a dataset component and data-aware controls on a form. In this sample, it is used to provide communication between the dataset and the Для просмотра ссылки Войдиили Зарегистрируйся where the dataset is displayed. To this end, the DataSet property of DataSource1 is set to qryAggregates and the DataSource property of DBGrid1 is set to DataSource1.
- Set an aggregate expression. Type your own aggregate expression on the Try edit box and press Enter for evaluation. For example: type MAX(Freight) and press Enter to see the maximum value of the Freight field on the Result edit box.
- Preset aggregate expressions. See the evaluation of the preset aggregate expressions.
Для просмотра ссылки Войди
Для просмотра ссылки Войди