Search code examples
sqldelphibde

How TQuery Configure the Parameter Values?


I was trying to figure out how TQuery is creating the final SQL String by correctly Replacing the values specified in the Params Property.

That is let the SQL string be SELECT * FROM tablename WHERE username= :Name and i give the value of :Name as 'abc' in Params option of TQuery. but the final SQL string is formed as SELECT * FROM tablename WHERE username='abc'. I just want to know how that is done.

I tried to Debug the application line by line to find the function that do the above specified job, But i couldn't. Someone please help.


Solution

  • A DB client (TQuery here) does not form the full SQL command. Instead it sends the parametrized command to the DB engine (server) where it's prepared for execution and client then sends only the parameter values.

    That's why this technique has its performance advantage, the DB engine does not need to prepare the same command over and over again. So you won't most probably find such implementation in any DB client component.