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

Quickly Learn How To Fetch A Table Using FireDAC In This IFDPhysCommand Delphi Sample

The sample uses the IFDPhysCommand interace to fetch rows from the current command cursor in the DatS table. To this end, the sample creates a command interface to:

  • Prepare a SELECT command.
  • Define the structure of the DatS table.
  • Open the command interface.
  • Fetch the table.
  • Print the fetched rows

Location

You can find the FetchTables sample project at:

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

How to Use the Sample

  1. Navigate to the location given above and open FetchTables.dproj.
  2. Press F9 or choose Run > Run.
  3. Click on the Use Connection Definition combo box and select an option.

Files

File in DelphiContains
FetchTables.dproj
FetchTables.dpr
The project itself.
fFetchTables.pas
fFetchTables.fmx
The main form.

Implementation

When you run the application, you see the following components that are configured on run time:

  • TComboBox object labeled as Use Connection Definition.When you click the Use Connection Definition combo box, the menu shows all the persistent connections defined on the file C:UsersPublicDocumentsEmbarcaderoStudioFireDACFDConnectionDefs.ini. Select an option in order to define a connection to a database. When the connection is defined, the sample uses the CreateCommand method of IFDPhysConnection to create a command interface. Then, the sample use some methods of this command interface to fetch rows from a table. Finally, the sample displays the fetched data using a TMemo object.To fetch data from a table, the sample implements the following steps:
    1. First, the sample uses the Prepare method in ordert to prepare the following SQL SELECT command: 'select * from {id Shippers}'.
    2. Secondly, the sample uses the Define method in order to define the structure of the DatS table.
    3. Thirdly, the sample calls the Open method to open the command interface created by the CreateCommand method of IFDPhysConnection.
    4. Finally, the sample calls the Fetch method in order to fetch rows from the DatS table.
  • TMemo object named Console. The sample uses this object to display the data fetched from the table.

Please refer to the link below for more details about this sample:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.IFDPhysCommand.FetchTables_Sample

Head over and check out the full source code for this FireDAC FetchTables Object Pascal sample on Embarcadero’s GitHub.


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