Can I get _evaluated_ query string as debug ?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
myicq
Posts: 8
Joined: Sat 01 Jun 2019 16:11

Can I get _evaluated_ query string as debug ?

Post by myicq » Thu 10 Sep 2020 08:02

Is there any way to read out the evaluated query string, for debug purposes ?

Example: I have a TUniQuery "q"

Code: Select all

  
    q.SQL.text := 'select * from products where id = :theid';
    q.paramByName('theid').asString := '123';
 
Now I would like to read out from q the final SQL sent to the server:

Code: Select all

   select * from products where id = '123';
Update: I can see from other posts (although using PgSQL) that it apparently is not possible to do. Can this be put on the wish list ? The query object must be able to compile the entire string.

oleg0k
Devart Team
Posts: 190
Joined: Wed 11 Mar 2020 08:28

Re: Can I get _evaluated_ query string as debug ?

Post by oleg0k » Fri 30 Oct 2020 10:31

Hello,
You can use the OnSQL event of the TUniSQLMonitor component to trace SQL statements sent to the server; you can also use the component together with the dbMonitor utility. See this page for more information: https://www.devart.com/unidac/docs/deva ... onitor.htm
However, most database systems support prepared statements, i.e., the statement is passed to the server as it was specified by the user, while the parameters are passed separately. The statement and parameters are then binded on the server and the statement is executed. In some database systems, the behavior is defined by the settings -- for example, in PostgreSQL you can set the protocol to ProtocolVersion = pv20. In this case, the complete statement is sent to the server as plain text.

wbr, Oleg
Devart Team

Post Reply