[yunqa.de] Re: TDISQLite3Statement.Sql16 shows "?" instead of bound arguments

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Sat, 27 Oct 2007 15:00:09 +0200

spamrbt <spamme@xxxxxxxxxx> wrote:

>I use sqlite3_trace to register a trace function. In that function, I
>log all the statements that are performed on the database. But some of
>them come in form of
>
>"SELECT id FROM instances WHERE name=?;"
>
>Of course, these are the statements with bound arguments.
>
>I tried to do logging the other way - log TDISQLite3Statement.Sql16
>every time I make a call to TDISQLite3Statement.Step, but Sql16 string
>does not contain bound arguments' values either.

Hosts parameters do not get expanded in the trace output. This is unfortunate, 
but it is a minor inconvenience comparied to the benefits of using host 
parameters.

>I would like to log statements with actual values instead of question
>marks. Any suggestions on how to do that?

I am not sure if it is an option for you not to host parameters and rewrite 
your queries accordingly. This would of course eliminate the benefits of host 
parameters:

  SELECT id FROM instances WHERE name='John';

Another alternative if your host parameter SQL is application generated 
(instead of user generated): Drop sqlite3_trace and log the SQL and parameter 
values manually when you prepare and bind your SQL statements.

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: