The Oracle_CQN sample shows you how to use Continuous Query Notification with Oracle databases using FireDAC.
Table of Contents
You can find the Oracle_CQN project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object Pascal\Database\FireDAC\Samples\DBMS Specific\Oracle\CQN
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
To this end, this sample connects a client with CHANGE NOTIFICATION privilege to an Oracle database server and uses an event alerter to notify about database table data changes.
The implementation of this sample takes into account the following considerations listed in Oracle CQN section of the Data Change Notifications topic of FireDAC.
|File in Delphi||Contains|
|The project itself.|
|The main form.|
Before running the sample, the main components are configured at design time using the Object Inspector as follows:
- Two TFDConnection objects named conOriginal and conChanges. These are the FireDAC connection objects that the sample use to connect to a DBMS. The sample sets the ConnectionDefName property of conOriginal to
- You can change the ConnectionDefName property to connect to a different Oracle server using a valid user name and password.
- The Params properties of conChanges are copied from conOriginal on run-time.
- Two TFDQuery objects named qOriginal and qChanges. These component are used to implement datasets capable of executing SQL queries.
- A TFDEventAlerter object named eaChanges. This component is used to handle the database change notifications.
- Three TDataSource objects named dsOriginal, dsChanges and dsRemote. These components provide interfaces between a dataset component and data-aware controls on a form. In this sample, these objects are used to provide communication between the datasets and the grids where the datasets are displayed. To this end, the sample sets the following properties:
- The DataSet property of dsOriginal, dsChanges and dsRemote is set to
- The DataSource property of grdOriginal, grdChanges and grdremote is set to
When you run the application, you see the following components:
- A TButton called Open DB. When you click this button, the sample takes the following steps:
- Connects conOriginal and activates qOriginal.
- Connects conChanges with the same parameters than conOriginal
- Activates the eaChanges event alerter.
- Activates qOriginal.Note: As commented in the Description, you should activate TFDEventAlerter before executing the tracked TFDQuery.
- A TButton called Start TX. When you click this button, the sample starts the transaction.
- A TButton called Commit TX. When you click this button, the sample commits the transaction.
- Three TGrids labeled as: Original data, Change View and “Remote” data. When you modify the data in the first grid, which contains the original data, it triggers a change in the second grid. The changes appear automatically on the second grid due to the event alerter. Moreover, the changes appear highligthed in yellow.
- Two TComboBoxes labeled as Data mode and Refresh mode. You can use these comboboxes to choose between different modes.
- Four TButtons above the third grid. Use these buttons to merge, commit and undo the changes.
- A TCheckBox labeled as Merge using stream. This check box allows you to emulate a remote data transfer.
Fore more information and official connections to other samples, follow the link below:
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition