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;;

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.

Need Your Help

How to get all info about start date to end date within a given date range?

sql oracle plsql

Recently I've been developing a leave management system. In this application I need a report like in a month wise employee leave statement.

SQL: Is this normalized? Extra field in an entity

sql entity-relationship database-normalization erd

I'm working on an ERD for a context where a therapist can make tests for clients to take, and there is a rule that after creating the test, the therapist can add items to it until the test has been...