开发者

Delphi: How to get the query that is passed to the server when parameters are used

I have a query with parameters inside a Devart TMSQuery.SQL. Something like

select * from customers
where customer = :CustomerID

in code I do

// Delphi
sqlcustomer.ParamByName('CustomerID'开发者_如何学运维).asinteger := 4;
sqlcustomer.open;

I want to debug and see the exact sql command sent to the server, if I try to use TMSQuery.sql I just have the :CustomerID, while I would like to have this:

select * from customers
where customer = 4

is there a quick way to have this without reading all the parameters and reconstructing manyally the query?

Of course I have a very big query with more than 100 parameters, this is why I need this


The actual SQL statement of a parameterized query which is sent to the server never contains textual representation of the parameter values. Instead, it uses placeholder characters, e.g. question marks. In your example, this would be select * from customers where customer = ? This is prepared on the server and parameter values are then sent by the client in a separate call.


If you're using Devart components then they have a TMSSQLMonitor component which may help. If you're connecting via odbc you can monitor the sql by turning on tracing on the odbc tab.

If you're using some other combination please describe.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜