From 36589437420a2ae71d50d4f4542d023d240a2d38 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 22 Sep 2015 23:24:35 +0100 Subject: Connector compatibility fix --- libodbcpp/selectcommand.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp index 07b185e..744c2c2 100644 --- a/libodbcpp/selectcommand.cpp +++ b/libodbcpp/selectcommand.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include ODBC::SelectCommand::SelectCommand(const Connection & c, const std::string & s) : DB::Command(s), @@ -14,7 +16,7 @@ ODBC::SelectCommand::SelectCommand(const Connection & c, const std::string & s) ODBC::SelectCommand::~SelectCommand() { - if (columns.size()) { + if (!columns->empty()) { RETCODE rc = SQLCloseCursor(hStmt); if (!SQL_SUCCEEDED(rc)) { throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::~SelectCommand SQLCloseCursor"); @@ -31,7 +33,7 @@ ODBC::SelectCommand::fetch() bool ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) { - if (columns.empty()) { + if (columns->empty()) { execute(); } RETCODE rc = SQLFetchScroll(hStmt, orientation, offset); @@ -43,7 +45,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) RETCODE diagrc = SQLGetDiagRec(SQL_HANDLE_STMT, hStmt, 1, sqlstatus, NULL, NULL, 0, NULL); if (SQL_SUCCEEDED(diagrc)) { if (!strncmp((const char*)sqlstatus, "01004", 5)) { - for (Columns::iterator i = columns.begin(); i != columns.end(); ++i) { + for (Columns::iterator i = columns->begin(); i != columns->end(); ++i) { boost::dynamic_pointer_cast(*i)->resize(); } return fetch(SQL_FETCH_RELATIVE, 0); @@ -56,7 +58,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) case SQL_SUCCESS: { bool resized = false; - for (Columns::iterator i = columns.begin(); i != columns.end(); ++i) { + for (Columns::iterator i = columns->begin(); i != columns->end(); ++i) { resized |= boost::dynamic_pointer_cast(*i)->resize(); } if (resized) { @@ -72,7 +74,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset) void ODBC::SelectCommand::execute() { - RETCODE rc = SQLExecute(hStmt); + RETCODE rc = SQLExecute(hStmt); if (!SQL_SUCCEEDED(rc)) { throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::execute SQLExecute"); } @@ -100,13 +102,13 @@ ODBC::SelectCommand::execute() case SQL_REAL: case SQL_FLOAT: case SQL_DOUBLE: - ncol = *columns.insert(DB::ColumnPtr(new FloatingPointColumn(this, colName, col))).first; + ncol = insertColumn(DB::ColumnPtr(new FloatingPointColumn(this, colName, col))); break; case SQL_SMALLINT: case SQL_INTEGER: case SQL_TINYINT: case SQL_BIGINT: - ncol = *columns.insert(DB::ColumnPtr(new SignedIntegerColumn(this, colName, col))).first; + ncol = insertColumn(DB::ColumnPtr(new SignedIntegerColumn(this, colName, col))); break; case SQL_TYPE_TIME: case SQL_INTERVAL_YEAR: @@ -122,18 +124,18 @@ ODBC::SelectCommand::execute() case SQL_INTERVAL_HOUR_TO_MINUTE: case SQL_INTERVAL_HOUR_TO_SECOND: case SQL_INTERVAL_MINUTE_TO_SECOND: - ncol = *columns.insert(DB::ColumnPtr(new IntervalColumn(this, colName, col))).first; + ncol = insertColumn(DB::ColumnPtr(new IntervalColumn(this, colName, col))); break; case SQL_TIMESTAMP: case SQL_DATETIME: case SQL_TYPE_DATE: case SQL_TYPE_TIMESTAMP: - ncol = *columns.insert(DB::ColumnPtr(new TimeStampColumn(this, colName, col))).first; + ncol = insertColumn(DB::ColumnPtr(new TimeStampColumn(this, colName, col))); break; case SQL_UNKNOWN_TYPE: throw Error("Unknown column type"); default: - ncol = *columns.insert(DB::ColumnPtr(new CharArrayColumn(this, colName, col, bindSize))).first; + ncol = insertColumn(DB::ColumnPtr(new CharArrayColumn(this, colName, col, bindSize))); break; }; boost::dynamic_pointer_cast(ncol)->bind(); -- cgit v1.2.3