From c39b0b6fcd769403397af247b3ccdbe3df1a60f2 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 16 Feb 2011 11:08:15 +0000 Subject: Fix the case when a bound buffer is too small and it's reported as success with info, not error (when did this start happening?) --- libodbcpp/selectcommand.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'libodbcpp') diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp index 2153862..32978a4 100644 --- a/libodbcpp/selectcommand.cpp +++ b/libodbcpp/selectcommand.cpp @@ -41,14 +41,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) } RETCODE rc = SQLFetchScroll(hStmt, orientation, offset); switch (rc) { - case SQL_SUCCESS: case SQL_SUCCESS_WITH_INFO: - for (Columns::iterator i = columns.begin(); i != columns.end(); i++) { - (*i)->onScroll(); - } - return true; - case SQL_NO_DATA: - return false; default: { SQLCHAR sqlstatus[6]; @@ -61,8 +54,17 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) return fetch(SQL_FETCH_RELATIVE, 0); } } + if (rc != SQL_SUCCESS_WITH_INFO) { + throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::fetch SQLFetch"); + } } - throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::fetch SQLFetch"); + case SQL_SUCCESS: + for (Columns::iterator i = columns.begin(); i != columns.end(); i++) { + (*i)->onScroll(); + } + return true; + case SQL_NO_DATA: + return false; } } -- cgit v1.2.3