FireDAC Tip: Write Database Independent SQL Commands With Escape Functions
February 6, 2021 by Konstantin Tomov
Escape sequences allow for writing DBMS-independent SQL commands. The sample predefines some escape function sequences. To execute a predefined escape function, right-click the Function edit box and choose a predefined escape function from the Для просмотра ссылки Войдиили Зарегистрируйся. Moreover, the sample allows you to write your own function. To this end, write text into the Function edit box and press Enter. Then, the sample uses the Для просмотра ссылки Войди или Зарегистрируйся, Для просмотра ссылки Войди или Зарегистрируйся, Для просмотра ссылки Войди или Зарегистрируйся and Для просмотра ссылки Войди или Зарегистрируйся methods of the Для просмотра ссылки Войди или Зарегистрируйся interface to process the escape function command text. Note: Go to the following Для просмотра ссылки Войди или Зарегистрируйся to see the syntax of the escape function sequences.

или Зарегистрируйся sequences, the sample configures the following components at design time using the Для просмотра ссылки Войди или Зарегистрируйся:
Для просмотра ссылки Войдиили Зарегистрируйся
Для просмотра ссылки Войдиили Зарегистрируйся
February 6, 2021 by Konstantin Tomov
Escape sequences allow for writing DBMS-independent SQL commands. The sample predefines some escape function sequences. To execute a predefined escape function, right-click the Function edit box and choose a predefined escape function from the Для просмотра ссылки Войди
Location
You can find the EscapeFunctions sample project at:- Start | Programs | Embarcadero RAD Studio Sydney | Samplesand then navigate to:
- Object PascalDatabaseFireDACSamplesPhys LayerIFDPhysCommandEscapeFunctions
- Subversion Repository:
- You can find Delphi code samples in Для просмотра ссылки Войди
или Зарегистрируйся. Search by name into the samples repositories according to your RAD Studio version.
- You can find Delphi code samples in Для просмотра ссылки Войди
How to Use the Sample
- Navigate to the location given above and open EscapeFunctionsdproj.
- Press F9 or choose Run > Run.
- Interact with the sample:
- Right-click the Function edit box and select a predefined escape function sequence.
- Write your own escape function and press Enter.

Files
File in Delphi | Contains |
---|---|
EscapeFunctions.dproj EscapeFunctions.dpr | The project itself. |
fEscapeFunctions.pas fEscapeFunctions.fmx | The main form. |
Implementation
To preset the Для просмотра ссылки Войди- A Для просмотра ссылки Войди
или Зарегистрируйся object named pmnFunc.The sample sets the Для просмотра ссылки Войдиили Зарегистрируйся property of this object with a menu of several predefined escape function sequences. - A Для просмотра ссылки Войди
или Зарегистрируйся object labeled as Function.The sample sets the Для просмотра ссылки Войдиили Зарегистрируйся property of the component to pmnFunc at design time. This setup allows you to choose a predefined escape function sequence in run time. To this end, right-click inside the edit box to see the popup menu. Then, choose a predefined escape function from the menu.
- A Для просмотра ссылки Войди
или Зарегистрируйся object labeled as Use Connection Definition.Click the Use Connection Definition combo box and select an option in order to Для просмотра ссылки Войдиили Зарегистрируйся to a database. The menu shows all the persistent connections defined on the file C:UsersPublicDocumentsEmbarcaderoStudioFireDACFDConnectionDefs.ini. When the connection is defined, the sample uses the Для просмотра ссылки Войдиили Зарегистрируйся method of Для просмотра ссылки Войдиили Зарегистрируйся to create a command interface. Then, the sample enables the edit boxes labeled as: Function, SQL string and Result. - A Для просмотра ссылки Войди
или Зарегистрируйся object labeled as Function.The sample uses this object to let you choose/write an escape function sequence:- To choose a predefined escape function, right-click inside the edit box to see the popup menu. Then, choose a predefined escape function.
- To write an escape function, type your own command text inside the edit box and press Enter.
или Зарегистрируйся, Для просмотра ссылки Войдиили Зарегистрируйся, Для просмотра ссылки Войдиили Зарегистрируйся and Для просмотра ссылки Войдиили Зарегистрируйся methods of the Для просмотра ссылки Войдиили Зарегистрируйся interface to process the scape function command text. - A Для просмотра ссылки Войди
или Зарегистрируйся object labeled as SQL string.The sample uses this edit box to show the SELECT command text that is executed. The Command text is the following: 'select distinct {fn %s} from {id test_free}', where %s corresponds to the escape function selected/written in the Function edit box. - A Для просмотра ссылки Войди
или Зарегистрируйся object labeled as Result.The sample uses this edit box to show the result of the escape function execution.
Для просмотра ссылки Войди
Для просмотра ссылки Войди