Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

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:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
    • Object PascalDatabaseFireDACSamplesComp LayerTFDLocalSQLxDBMS
  • Subversion Repository:
    • You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
xdbms

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:

  • Set up an in-memory SQLite local connection (FDConnection1) as a query source from the Local SQL engine (FDLocalSQL1).
  • Perform a local SQL query (FDQuery1).
  • Connect the datasets (qOrders and qDetails) to the Local SQL engine.

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.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES