On 4/25/08, Cole Tuininga <[EMAIL PROTECTED]> wrote: > Hi all - > > I'm trying sqlite for the first time and am having a small problem. > I'm using the C api. > > I've got a prepared select query that I keep binding new values to > (tangental question - is it enough to just keep rebinding to a query? > Or do I need to call sqlite3_clear_bindings every time?). The table > in question is pretty simple: key/value for the moment. The select > looks up a value based on the key. The thing is that I'm only making > requests for keys that I know exist, and this doesn't seem to be > giving me any results. That is, sqlite3_step is returning SQLITE_DONE > after the first call each time I run it. > > I'm making sure to call sqlite3_reset on the handle each time. > > The question is, is there an easy way to extract the actual query > (with the bound variable set) from the statement handle? I'm looking > to make sure that I'm actually binding the expected value into the > query. Thanks. >
Here is what I do in the Perl world for this problem -- # Create a string with the bound vars to write to a log $sql = "SELECT col FROM table WHERE col = '<bound value here>'; # Write this $sql to a log file $log->info(localtime . ": " . $sql . "\n"); # Now bind and run the query for real $sth = $dbh->prepare(qq{SELECT col from table WHERE col = ?}); $sth->execute('<bound value here>'); > > -- > Cole Tuininga > http://www.tuininga.org/ -- Puneet Kishor _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users