Modify SQL text on the fly

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 1
Joined: Fri 15 Feb 2019 15:30

Modify SQL text on the fly

Post by Botaniil » Fri 15 Feb 2019 15:36


i have a lot of old delphi codes like this:

SomeQuery.SQL.Text:='select Name from SomeTable where Version=:Version ';

now application adopted for work with PostreSQL via Unidac and code should like this:

'select "Name" from SomeTable where "Version"=:"Version" ';

So, please, help me to choose appropriate TUniQuery methods (to override) for change query text on the fly
There are a variety of places: BeforeOpen, AssembleSQL, InternalOpen, Macros....TUniQuery.SQL or TUniQuery.FCommand.SQL..etc

And how to synchronize parameters (or query params parsing) for updated quoted identifiers?

Posts: 166
Joined: Sat 23 Feb 2013 18:46

Re: Modify SQL text on the fly

Post by FCS » Tue 19 Feb 2019 12:42


Try use:

- Prepare method before setting parameters and Open
- 'select "Name" from SomeTable where "Version"=:Version ';

PostgreSQL dislikes big letters in names, but supports them by "".


Devart Team
Posts: 1477
Joined: Mon 06 Jul 2015 11:34

Re: Modify SQL text on the fly

Post by MaximG » Fri 22 Feb 2019 12:31

Please explain the reason of the neccessity for quoting field and parameter names as it is shown in the query you provided.
You can change the text of a SQL query by referring to the 'SomeQuery.SQL.Text' property. Explain, please, in what cases you need to use such changes in your projects.

Post Reply