"Jeff Godfrey" <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I'm working on a tcl/sqlite based app.  For the first time, I 
> just registered a callback with the trace method so I could "see"
> all of my SQL interactions as they happen.  While it does work as
> advertised, it seems to output each SQL statement prior to having
> resolved any variables found in the statement.  For instance,
> when the following SQL statement...
> 
> dbPart eval {UPDATE OR REPLACE property SET value = $status
>                          WHERE key = 'status'}
> 
> .... hits my registered trace command, the "$status" variable has
> not yet been resolved, so it just outputs a literal "$status".  
> It would seem to be much more helpful if the variable were resolved 
> prior to firing the trace callback.
> 
> Though I haven't tried it, I assume that replacing the curly-braces
> in my original statement with double-quotes would fix the problem,
> as then the Tcl parser would resolve the variable prior to executing
> the command.  I haven't been coding my SQL statements like that as 
> I was under the impression that the above is a more accepted style
> (and maybe even faster?), though I don't know where I found info to 
> that effect.  
> 
> So, should the TRACE command work differently in this case or should
> I change my SQL-coding style?  Thoughts?
> 

The use of curly-braces is the preferred style.  curly braces are
both faster and they help prevent SQL injection bugs in your program.

What is really happening behind the scenes is that SQLite understands
the "$status" token as a host-parameter.  You could just as well
say ":status".  They both work the same.  Then the TCL interface
binds the values of TCL variables to these host parameters.

Yes, it is a bummer that the hosts parameters do not get expanded
in the trace output.  But that is a minor inconvenience comparied
to the benefits of using host parameters.

--
D. Richard Hipp  <[EMAIL PROTECTED]>


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to