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
Table of Contents
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
- Navigate to the location given above and open
FetchTables.dproj
. - Press F9 or choose Run > Run.
- Click on the Use Connection Definition combo box and select an option.
Files
File in Delphi | Contains |
---|---|
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:
- A 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:- First, the sample uses the Prepare method in ordert to prepare the following SQL
SELECT
command:'select * from {id Shippers}'
. - Secondly, the sample uses the Define method in order to define the structure of the DatS table.
- Thirdly, the sample calls the Open method to open the command interface created by the CreateCommand method of IFDPhysConnection.
- Finally, the sample calls the Fetch method in order to fetch rows from the DatS table.
- First, the sample uses the Prepare method in ordert to prepare the following SQL
- A 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