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

Learn More About The Powerful Macros Property Of IFDPhysCommand With FireDAC In Delphi

The sample allows you to modify the macro values at run time.Note: See the Preprocessing Command Text topic for more information about parameterizing SQL command texts.

Location

You can find the Macros sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
    • Object PascalDatabaseFireDACSamplesPhys LayerIFDPhysCommandMacros
  • 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 IFDPhys_Macros.dproj.
  2. Press F9 or choose Run > Run.
  3. Click on the Use Connection Definition combo box and select an option.
  4. Interact with the sample:
    • Modify the values of the Macros to retrieve the desired data. For example, change 'Address' to 'First Name'.
    • Click the Fetch button and see the retrieved data.

Files

File in DelphiContains
IFDPhys_Macros.dproj
IFDPhys_Macros.dpr
The project itself.
fMacros.pas
fMacros.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 sets up five Macros that are used on the SQL statement: COLUMNTABIDSignIDVALUE. Finally, the sample fills the lstMacros list editor with the predefined Macros and enables the lstMacrosData type and Fetch objects.
  • TValueListEditor object named lstMacros.The sample use this object to show and modify the list of Macros. Modify the value of any Macro to modify the SQL query. For example, change 'Address' to 'First Name' and click the fetch button. The information that retrieves the SQL query is different.
  • TComboBox object labeled as Data type.This object allows you to change the data type of the selected Macros value.
  • Tbutton object called Fetch.Click the Fetch button to retrieve the desired data using the defined Macros and the following SQL command text: 'select !column from !tab where (!id !Sign !idValue)'. To this end, the sample uses the PrepareDefineOpen and Fetch methods of the command interface created before.
  • TMemo object named mmSQL.The sample uses this object to show the SQL command text.
  • TMemo object named Console.The sample uses this object to display the retrieved data from the SELECT statement.

Fore more information you can follow the link below:

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

Head over and check out the full source code for the FireDAC macros sample on Embarcadero’s GitHub.


What's New for RAD Studio 11

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

Related posts
C++DelphiRAD Studio

The High-Performance Future Of AI Is REST APIs

CodeDelphiTech Partner

How To Create Your Own Components For The FastReport Dialog

C++Code

What Are The New C++ Posts From LearnCPlusPlus.org?

DelphiRAD Studio

Delphi in the Galileo Project in Brazil

Leave a Reply

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

IN THE ARTICLES