reset after failed step

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

reset after failed step

Jan Danielsson
Hello,

   Is this (conceptually) correct:

   -------------
   .. bind arguments ..

   sqlrc = sqlite3_step(stmt);
   if(sqlrc == SQLITE_ROW || sqlrc == SQLITE_DONE) {
     sqlrc = sqlite3_reset(stmt);
     assert(sqlrc == SQLITE_OK);
   }

   .. bind other arguments ..

   sqlrc = sqlite3_step(stmt);
   if(sqlrc == SQLITE_ROW || sqlrc == SQLITE_DONE) {
     sqlrc = sqlite3_reset(stmt);
     assert(sqlrc == SQLITE_OK);
   }

   sqlrc = sqlite3_finalize(stmt);
   assert(sqlrc == SQLITE_OK);
   -------------

   I.e. reset should only be run on ROW and DONE.  On step error, the
statement's state is reset implicitly by sqlite3_step()?

--
Kind regards,
Jan Danielsson

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: reset after failed step

Richard Hipp-3
On 3/17/17, Jan Danielsson <[hidden email]> wrote:
>
>    I.e. reset should only be run on ROW and DONE.  On step error, the
> statement's state is reset implicitly by sqlite3_step()?

No.  Always run sqlite3_reset().

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users