On Fri, Mar 21, 2008 at 07:09:29PM -0600, John Stanton scratched on the wall:
> Use this sequence -
> 
>    sqlite3_prepare_v2
>      while not finished
>        sqlite3_bind_xxx
>        sqlite3_step
>      until SQLITE_DONE
>        sqlite3_reset
>      repeat
>    sqlite3_finalize
> 
> The sqlite3_reset readies the compiled statement for binding with 
> another value.

  It isn't a bad idea to put a sqlite3_clear_bindings() right
  before or after the _reset.  Reset gets the statement ready for
  another transaction, but it doesn't clear any of the existing
  bindings.  _clear_bindings resets them all to NULL.

  In theory, this only matters if you fail to bind all the parameters
  on every loop, but the defensive programmer in me likes the idea of
  keeping data from one update from "leaking" to the next update if
  something goes wrong.  It also means the state of your stmt is
  exactly the same each time you enter your update loop, which can
  simplify your bind logic if your application/database uses default
  values.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"'People who live in bamboo houses should not throw pandas.' Jesus said that."
   - "The Ninja", www.AskANinja.com, "Special Delivery 10: Pop!Tech 2006"
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to