Forum > Databases

How do I access the full sql+params in a TSQLQuery?

<< < (3/3)

rvk:

--- Quote from: MarkMLl on May 21, 2022, 09:34:51 am ---
--- Quote from: rvk on May 20, 2022, 10:46:06 pm ---But the parameters are transferred as binary to the server, along with the SQL.

--- End quote ---
Not necessarily, that depends on the server API. For example using pqconnection.pp as an example, a query can be submitted via PQExec() or via PQexecParams() etc. which prepares the parameters in PostgreSQL-specific form.
--- End quote ---
Even then... in PQexecParams() the parameters are still transferred separate from the SQL.


--- Quote from: MarkMLl on May 21, 2022, 09:34:51 am ---(1) From the Pascal POV, it can be useful to use parameterisation. But at that point there should- IMO- at least be the option of having the database libraries build a parameterless query themselves, which is available for inspection (2) before being sent to the server.
--- End quote ---
I agree with the first part. It can be useful for debugging. But it doesn't need to be sent to the server (2). At least not standard. Maybe for debugging you could do that one to see if it has the same results as with the params but that's just for debugging.


--- Quote from: MarkMLl on May 21, 2022, 09:34:51 am ---In practice, I'm not even sure to what extent server-omplemented parameterisation improves efficiency these days, particularly if a server is told which subqueries will always return the same result for the same parameters.
--- End quote ---
I'm sure this is still (and can be) vastly more efficient. Especially in cases of bulk inserts where the SQL/PLAN is prepared (up to 100% more efficient).

So, although I agree a debugging function could be useful to replace parameters in a TSQLQuery to a parameterless string, I'm not sure this really needs to be a part of the (deeper) library. This could just be a more simple helper function.

TSQLQuery.GetExpandedSQL and TSQLQuery.ExecuteExpandedSQL for example.
And this would still be done with a form of ReplaceString I showed earlier and only used when you want to debug something.

But that's just my opinion.

Navigation

[0] Message Index

[*] Previous page

Go to full version