Learn How Easy It Is To Apply Updates With TFDQuery.OnUpdateRecord In Delphi
January 21, 2021 by Konstantin Tomov
The OnUpdateRecord sample shows you how to cache the user changes when using read-only dataset and then, how to apply updates on behalf of queries that cannot post updates directly. To this end, the sample uses the Для просмотра ссылки Войдиили Зарегистрируйся event of Для просмотра ссылки Войди или Зарегистрируйся and the Для просмотра ссылки Войди или Зарегистрируйся object.
или Зарегистрируйся as follows:
Note: In the RDBMS it has one-to-many relation between Categories and Products tables.
For more details, please follow the link to the original post:
Для просмотра ссылки Войдиили Зарегистрируйся
Для просмотра ссылки Войдиили Зарегистрируйся
January 21, 2021 by Konstantin Tomov
The OnUpdateRecord sample shows you how to cache the user changes when using read-only dataset and then, how to apply updates on behalf of queries that cannot post updates directly. To this end, the sample uses the Для просмотра ссылки Войди
Location
You can find the CentralizedCachedUpdates sample project at:- Start | Programs | Embarcadero RAD Studio Sydney | Samplesand then navigate to:
- Object PascalDatabaseFireDACSamplesComp LayerTFDQueryCachedUpdatesOnUpdateRecord
- Subversion Repositories:
- 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 Qry_CachedUpdates.dproj.
- Press F9 or choose Run > Run.
Files
File in Delphi | Contains |
---|---|
Qry_CachedUpdates.dproj Qry_CachedUpdates.dpr | The project itself. |
fCachedUpdates.pas fCachedUpdates.fmx | The main form. |
Implementation
Before running the sample, the main components are configured at design time using the Для просмотра ссылки Войди- A Для просмотра ссылки Войди
или Зарегистрируйся object named qryProducts. This component is used to implement a dataset capable of executing SQL queries. The following setup is needed: - The Для просмотра ссылки Войди
или Зарегистрируйся property is configured to specify the FireDAC connection object that is used to connect to a DBMS. - The Для просмотра ссылки Войди
или Зарегистрируйся property of qryProducts is set to:
SQL:
select p.*, c.CategoryName
from {id Products} p left outer join {id Categories} c on p.CategoryID = c.CategoryID
order by ProductID
- The Для просмотра ссылки Войди
или Зарегистрируйся property is set to True. It means that the dataset will log data changes without immediately applying them to the database. - Two Для просмотра ссылки Войди
или Зарегистрируйся objects named usProducts and usCategories. Both objects are used to provide SQL statements for posting updates from Для просмотра ссылки Войдиили Зарегистрируйся. To this end, the following setup is needed: - The Для просмотра ссылки Войди
или Зарегистрируйся property of usProducts is set to:
SQL:
UPDATE {id Products} SET
ProductName = :NEW_ProductName,
SupplierID = :NEW_SupplierID, CategoryID = :NEW_CategoryID,
QuantityPerUnit = :NEW_QuantityPerUnit, UnitPrice = :NEW_UnitPrice,
UnitsInStock = :NEW_UnitsInStock, UnitsOnOrder = :NEW_UnitsOnOrder,
ReorderLevel = :NEW_ReorderLevel, Discontinued = :NEW_Discontinued
WHERE
ProductID = :OLD_ProductID
- The Для просмотра ссылки Войди
или Зарегистрируйся property of usCategories is set to:
SQL:
UPDATE {id Categories} SET
CategoryName = :NEW_CategoryName
WHERE
CategoryID = :OLD_CategoryID
- A Для просмотра ссылки Войди
или Зарегистрируйся objects named dsProducts. 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 following properties are set: - The DataSet property of dsProducts is set to qryProducts.
- The DataSource property of DBGrid1 is set to dsProducts.
For more details, please follow the link to the original post:
Для просмотра ссылки Войди
Для просмотра ссылки Войди