diff --git a/include/SQLiteCpp/Statement.h b/include/SQLiteCpp/Statement.h index 13a122e..31f60cb 100644 --- a/include/SQLiteCpp/Statement.h +++ b/include/SQLiteCpp/Statement.h @@ -75,11 +75,10 @@ public: /// Finalize and unregister the SQL query from the SQLite Database Connection. ~Statement(); - /// Reset the statement to make it ready for a new execution. + /// Reset the statement to make it ready for a new execution. Throws an exception on error. void reset(); - - /// Reset the statement to make it ready for a new execution. Returns the sqlite result code - /// instead of throwing an exception on error. + + /// Reset the statement. Returns the sqlite result code instead of throwing an exception on error. int tryReset() noexcept; /** @@ -350,7 +349,7 @@ public: * @throw SQLite::Exception in case of error */ bool executeStep(); - + /** * @brief Try to execute a step of the prepared query to fetch one row of results, returning the sqlite result code. * diff --git a/src/Statement.cpp b/src/Statement.cpp index 11068a6..4b07ae1 100644 --- a/src/Statement.cpp +++ b/src/Statement.cpp @@ -52,9 +52,7 @@ Statement::~Statement() // Reset the statement to make it ready for a new execution (see also #clearBindings() bellow) void Statement::reset() { - mbOk = false; - mbDone = false; - const int ret = sqlite3_reset(mStmtPtr); + const int ret = tryReset(); check(ret); } @@ -62,8 +60,7 @@ int Statement::tryReset() noexcept { mbOk = false; mbDone = false; - const int ret = sqlite3_reset(mStmtPtr); - return ret; + return sqlite3_reset(mStmtPtr); } // Clears away all the bindings of a prepared statement (can be associated with #reset() above). @@ -274,7 +271,8 @@ bool Statement::executeStep() return mbOk; // true only if one row is accessible by getColumn(N) } -int Statement::tryExecuteStep() noexcept { +int Statement::tryExecuteStep() noexcept +{ const int ret = sqlite3_step(mStmtPtr); if (SQLITE_ROW == ret) // one row is ready : call getColumn(N) to access it { @@ -290,7 +288,7 @@ int Statement::tryExecuteStep() noexcept { mbOk = false; mbDone = false; } - + return ret; }