Hi, Keith, On Mon, Jun 4, 2018 at 11:45 AM, Keith Medcalf <kmedc...@dessus.com> wrote: > Works just fine for me ... > > > #include "sqlite3.h" > #include <stdio.h> > > void main(int argc, char** argv) > { > sqlite3* db = 0; > sqlite3_stmt* stmt = 0; > char* rest = 0; > int rc = 0; > int value = 0; > sqlite3_open(":memory:", &db); > rc = sqlite3_prepare_v2(db, "select value from generate_series where > start=1 and stop=10;", -1, &stmt, (void*)&rest); > if (rc != SQLITE_OK) > { > printf("Error %d during prepare\n", rc); > return; > } > printf("\nLoop 1, no reset\n"); > for (;;) > { > rc = sqlite3_step(stmt); > if (rc == SQLITE_DONE) > { > printf("!\n"); > rc = sqlite3_reset(stmt); > printf("sqlite3_reset returns %d\n", rc); > break; > } > if (rc == SQLITE_ROW) > { > value = sqlite3_column_int(stmt, 0); > printf("%d ", value); > continue; > } > printf("Error during stepping %d\n", rc); > break; > } > printf("\nLoop 2, after reset\n"); > for (;;) > { > rc = sqlite3_step(stmt); > if (rc == SQLITE_DONE) > { > printf("!\n"); > rc = sqlite3_reset(stmt); > printf("sqlite3_reset returns %d\n", rc); > break; > } > if (rc == SQLITE_ROW) > { > value = sqlite3_column_int(stmt, 0); > printf("%d ", value); > continue; > } > printf("Error during stepping %d\n", rc); > break; > } > } > > gcc test.c -L. -lsqlite3 -o test.exe
Currently running w/MSVC 2010 under Win 8.1. I also presume you are testing under the latest SQLite source? Thank you. > > 2018-06-04 10:41:10 MinGW [D:\work] >>test > > Loop 1, no reset > 1 2 3 4 5 6 7 8 9 10 ! > sqlite3_reset returns 0 > > Loop 2, after reset > 1 2 3 4 5 6 7 8 9 10 ! > sqlite3_reset returns 0 > > > > --- > The fact that there's a Highway to Hell but only a Stairway to Heaven says a > lot about anticipated traffic volume. > > >>-----Original Message----- >>From: sqlite-users [mailto:sqlite-users- >>boun...@mailinglists.sqlite.org] On Behalf Of Igor Korot >>Sent: Sunday, 3 June, 2018 22:32 >>To: Discussion of SQLite Database; General Discussion of SQLite >>Database >>Subject: [sqlite] Reset the cursor >> >>Hi, All, >>After executing the following: >> >>int res = sqlite3_prepare_v2( ... stmt ); >>while( ; ; ) >>{ >> res = sqlite3_step( stmt ); >> if( res == SQLITE_ROW ) >> { >> // process the record >> } >> else if( res == SQLITE_DONE ) >> break; >> else >> { >> // error procressing >> } >>} >> >>Now I'd like the cursor in the recordset of the "stmt" to go to the >>record 1 >>so I can process those records again. >> >>I thought that this will be a job of sqlite_reset(), but when I >>called >>it and started re-processing the recordset I got SQLITE_DONE on the >>very first iteration. >> >>So, how do I reset the cursor to the first record? >> >>Thank you. >>_______________________________________________ >>sqlite-users mailing list >>sqlite-users@mailinglists.sqlite.org >>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users