summaryrefslogtreecommitdiff
path: root/libodbcpp/selectcommand.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-11-25 19:26:04 +0000
committerrandomdan <randomdan@localhost>2010-11-25 19:26:04 +0000
commitbf8c4b6990a203c28b92ca09e170d0cbea206092 (patch)
tree9591f50c8c39b7b33a4b4659b0c997545aa7c79a /libodbcpp/selectcommand.cpp
parentTidy up jam stuff (diff)
downloadlibdbpp-odbc-bf8c4b6990a203c28b92ca09e170d0cbea206092.tar.bz2
libdbpp-odbc-bf8c4b6990a203c28b92ca09e170d0cbea206092.tar.xz
libdbpp-odbc-bf8c4b6990a203c28b92ca09e170d0cbea206092.zip
Use proper ODBC SQL_SUCCEEDED macro, not SQL_SUCCESS comparison
Diffstat (limited to 'libodbcpp/selectcommand.cpp')
-rw-r--r--libodbcpp/selectcommand.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp
index 177a84e..9df0046 100644
--- a/libodbcpp/selectcommand.cpp
+++ b/libodbcpp/selectcommand.cpp
@@ -18,8 +18,8 @@ ODBC::SelectCommand::~SelectCommand()
}
}
if (columns.size()) {
- RETCODE rc;
- if ((rc = SQLCloseCursor(hStmt)) != SQL_SUCCESS) {
+ RETCODE rc = SQLCloseCursor(hStmt);
+ if (!SQL_SUCCEEDED(rc)) {
throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLCloseCursor",
__FUNCTION__);
}
@@ -35,6 +35,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();
}
@@ -63,15 +64,15 @@ void
ODBC::SelectCommand::execute()
{
RETCODE rc = SQLExecute(hStmt);
- if (rc != SQL_SUCCESS) {
+ if (!SQL_SUCCEEDED(rc)) {
throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLExecute",
__FUNCTION__);
- }
- SQLSMALLINT colCount;
- if ((rc = SQLNumResultCols(hStmt, &colCount)) != SQL_SUCCESS) {
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLNumResultCols",
- __FUNCTION__);
- }
+ }
+ SQLSMALLINT colCount;
+ if (!SQL_SUCCEEDED(rc = SQLNumResultCols(hStmt, &colCount))) {
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLNumResultCols",
+ __FUNCTION__);
+ }
if (colCount < 1) {
throw Error("%s: No result columns", __FUNCTION__);
}
@@ -81,14 +82,15 @@ ODBC::SelectCommand::execute()
SQLSMALLINT nameLen, dp, nullable, bindType;
SQLUINTEGER bindSize;
int sqlcol = col + 1;
- if ((rc = SQLDescribeCol(hStmt, sqlcol, _colName, sizeof(_colName), &nameLen, &bindType,
- &bindSize, &dp, &nullable)) != SQL_SUCCESS) {
+ if (!SQL_SUCCEEDED(rc = SQLDescribeCol(hStmt, sqlcol, _colName, sizeof(_colName), &nameLen, &bindType,
+ &bindSize, &dp, &nullable))) {
throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLDescribeCol for %d",
__FUNCTION__, col);
}
Glib::ustring colName((const char *)_colName, nameLen);
switch (bindType) {
case -9:
+ case -10:
case SQL_CHAR:
case SQL_VARCHAR:
case SQL_LONGVARCHAR: