x, On Mon, Jun 4, 2018 at 10:54 AM, x <tam118...@hotmail.com> wrote: > If the first loop exits with res3 == SQLITE_DONE then !result will be true > and the second loop should process exactly the same (assuming underlying data > is unchanged). I can’t see why the code below wouldn’t work although I’m > confused by the fact you say that sqlite3_step(stmt3) returns SQLITE_DONE > immediately after the sqlite3_reset(stmt3) but later say it’s returning 1 > (SQLITE_ERROR).
Yes, first loop exits with the SQLITE_DONE. The call to sqlite3_reset() return 0 (success). But the very first call to sqlite3_step() returns 1 (error). Then the code goes to execute error handling branch where it calls sqlite3_errcode(). This function returns 0 - which I think means no error is encountered during the previous SQLite call. I can try to get an external error code or the error message though using the appropriate function. Thank you. > > > int result = 0, res3 = SQLITE_OK; > for( ; ; ) > { > res3 = sqlite3_step( stmt3 ); > if( res3 == SQLITE_ROW ) > { > // initial processing > } > else if( res3 == SQLITE_DONE ) > break; > else > { > // error handling > result = 1; > } > } > if( !result ) > { > res3 = sqlite3_reset( stmt3 ); > for( ; ; ) > { > res3 = sqlite3_step( stmt3 ); > if( res3 == SQLITE_ROW ) > { > // actual processing > } > else if( res3 == SQLITE_DONE ) > break; > else > { > // error handling > } > } > } > > Not sure where this code belongs > > if( res3 != SQLITE_DONE ) > break; > } > > _______________________________________________ > 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