Page 1 of 1

Can I get _evaluated_ query string as debug ?

Posted: Thu 10 Sep 2020 08:02
by myicq
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.

Re: Can I get _evaluated_ query string as debug ?

Posted: Fri 30 Oct 2020 10:31
by oleg0k
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