Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Learn How To Use The Powerful In-Memory FireDAC Local SQL Engine In Delphi

The xDBMS sample shows you how use the TFDLocalSQL class to implement a cross-DBMS query application. To this end, each queryable dataset must be registered with the Local SQL engine using the DataSets collection property.Note: The Local SQL feature allows executing SQL commands, where the TDataSet descendants are used instead of the database tables.

Location

You can find the xDBMS sample project at:

How to Use the Sample

  1. Navigate to the location given above and open xDBMS.dproj.
  2. Press F9 or choose Run > Run.

Files

File in DelphiContains
xDBMS.dproj
xDBMS.dpr
The project itself.
fMain.pas
fMain.fmx
The main form.

Implementation

To setup Local SQL engine for a cross-DBMS query application, the sample has to perform the following steps:

To this end, the sample implement the following steps:

  1. Setup connection and query to “Orders” table in SQLite database and link the dataset to the Local SQL engine. To this end, the following components are needed:
  2. Setup connection and query to “Orders Details” table in MSAccess database and link the dataset to the Local SQL engine. To this end, the sample uses the following components:
  3. Setup SQLite in-memory connection. To this end, the sample sets up the following components:
  4. Execute a SELECT query on above datasets using:
    • TFDQuery object named FDQuery1.
      • The Connection property is set to FDConnection1.
      • The SQL property set to SELECT QO.*, QD.* FROM qOrders QO LEFT JOIN qDetails QD ON QO.OrderID = QD.OrderID ORDER BY QO.OrderID

Note: All the configuration of these components is done using the Object Inspector at design time.

When you run the application, click on the Open/Close button in order to set the Active property of FDQuery1 to True. It executes the SELECT query on the datasets registered with this Local SQL engine. Then, the records from the registered datasets are displayed on a TDBGrid component.

For more information about this sample you can refer to the link below:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.TFDLocalSQL.xDBMS_Sample

Head over and check out the full source code for the FireDAC local SQL sample for Delphi.

Exit mobile version