Re: [sqlite] Multiple Row Updates
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
Re: [sqlite] Multiple Row Updates
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. Derek Developer wrote: > Just wanted to check that there is no "reset" statement that I can use with > UPDATE's. > > My understanding is that for multiple Row updates the complete sequence needs > to be executed for each row ie: > > "UPDATE mytable SET ' name=?, street=?, Phone=? WHERE ROWID=333" > Prepare > Bind the data > step > finalize > > then the next row must complete the same sequence ie: > "UPDATE mytable SET ' name=?, street=?, Phone=? WHERE ROWID=333" > Prepare > Bind the data > step > finalize > > Obviously I can do all these within a BEGIN/END TRANSACTION > > but was just wondering if there is any way to use the reset statement and > update the ROWID? > > This would save a lot of time for large numbers of rows. > > Testing with Seinfeld data from Michael Owens excellent book: > http://books.google.com/books?id=VsZ5bUh0XAkC=PA75=PA75=sqlite+seinfeld=web=u42Lep_3F7=A3whrQ0XJbW7DBQbPhyspKdHJuc=en > Download: > http://www.apress.com/book/downloadfile/2847 > > > (also would love to figure out how to respond to my own threads. I cannot > seem to find the link in the digests I am getting at my email account) > > > > > - > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Multiple Row Updates
Just wanted to check that there is no "reset" statement that I can use with UPDATE's. My understanding is that for multiple Row updates the complete sequence needs to be executed for each row ie: "UPDATE mytable SET ' name=?, street=?, Phone=? WHERE ROWID=333" Prepare Bind the data step finalize then the next row must complete the same sequence ie: "UPDATE mytable SET ' name=?, street=?, Phone=? WHERE ROWID=333" Prepare Bind the data step finalize Obviously I can do all these within a BEGIN/END TRANSACTION but was just wondering if there is any way to use the reset statement and update the ROWID? This would save a lot of time for large numbers of rows. Testing with Seinfeld data from Michael Owens excellent book: http://books.google.com/books?id=VsZ5bUh0XAkC=PA75=PA75=sqlite+seinfeld=web=u42Lep_3F7=A3whrQ0XJbW7DBQbPhyspKdHJuc=en Download: http://www.apress.com/book/downloadfile/2847 (also would love to figure out how to respond to my own threads. I cannot seem to find the link in the digests I am getting at my email account) - Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users