From 93c6bb0725536f13bda6f425d0baa459ec9d0785 Mon Sep 17 00:00:00 2001 From: Aleksandar Fabijanic Date: Wed, 16 Jul 2008 21:02:56 +0000 Subject: [PATCH] removed ODBCStatementImpl stored procedure hack renamed TypeInfo::getSafeInfo to tryGetInfo --- .../include/Poco/Data/ODBC/ODBCStatementImpl.h | 2 +- Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h | 4 ++-- Data/ODBC/src/Binder.cpp | 7 +++---- Data/ODBC/src/ODBCStatementImpl.cpp | 17 ++--------------- Data/ODBC/src/TypeInfo.cpp | 2 +- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h b/Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h index e2b9dab82..c16843f32 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h +++ b/Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h @@ -129,7 +129,7 @@ private: void clear(); /// Closes the cursor and resets indicator variables. - void doBind(bool clear = true, bool reset = false); + void doBind(); /// Binds parameters. void makeInternalExtractors(); diff --git a/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h b/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h index 4f76a73c3..b0df96002 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h +++ b/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h @@ -110,9 +110,9 @@ public: DynamicAny getInfo(SQLSMALLINT type, const std::string& param) const; /// Returns information about specified data type as specified by parameter 'type'. /// The requested information is specified by parameter 'param'. - /// Will fail with a Poco::NotFoundException if the param is not found + /// Will fail with a Poco::NotFoundException thrown if the param is not found - bool getSafeInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const; + bool tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const; /// Returns information about specified data type as specified by parameter 'type' in param result. /// The requested information is specified by parameter 'param'. /// Will return false if the param is not found. The value of result will be not changed in this case. diff --git a/Data/ODBC/src/Binder.cpp b/Data/ODBC/src/Binder.cpp index a2ada694d..571284195 100644 --- a/Data/ODBC/src/Binder.cpp +++ b/Data/ODBC/src/Binder.cpp @@ -439,10 +439,9 @@ void Binder::getColSizeAndPrecision(std::size_t pos, bool found(false); if (_pTypeInfo) { - found = _pTypeInfo->getSafeInfo(cDataType, "COLUMN_SIZE", tmp); - if (found) - colSize = tmp; - found = _pTypeInfo->getSafeInfo(cDataType, "MINIMUM_SCALE", tmp); + found = _pTypeInfo->tryGetInfo(cDataType, "COLUMN_SIZE", tmp); + if (found) colSize = tmp; + found = _pTypeInfo->tryGetInfo(cDataType, "MINIMUM_SCALE", tmp); if (found) { decDigits = tmp; diff --git a/Data/ODBC/src/ODBCStatementImpl.cpp b/Data/ODBC/src/ODBCStatementImpl.cpp index 9ed3635b6..39643323e 100644 --- a/Data/ODBC/src/ODBCStatementImpl.cpp +++ b/Data/ODBC/src/ODBCStatementImpl.cpp @@ -110,13 +110,6 @@ void ODBCStatementImpl::compileImpl() _pBinder = new Binder(_stmt, maxFieldSize, bind, pDT); - // This is a hack to conform to some ODBC drivers behavior (e.g. MS SQLServer) with - // stored procedure calls: driver refuses to report the number of columns, unless all - // parameters for the stored procedure are bound. Since number of columns is essential - // information for the internal extraction creation, in order to allow for querying it, - // these calls must occur before. - fixupBinding(); doBind(false, true); - makeInternalExtractors(); doPrepare(); @@ -207,9 +200,9 @@ bool ODBCStatementImpl::canBind() const } -void ODBCStatementImpl::doBind(bool clear, bool reset) +void ODBCStatementImpl::doBind() { - if (clear) this->clear(); + this->clear(); Bindings& binds = bindings(); if (!binds.empty()) { @@ -219,12 +212,6 @@ void ODBCStatementImpl::doBind(bool clear, bool reset) if (it != itEnd && 0 == _affectedRowCount) _affectedRowCount = static_cast((*it)->numOfRowsHandled()); - if (reset) - { - it = binds.begin(); - for (; it != itEnd; ++it) (*it)->reset(); - } - for (std::size_t pos = 0; it != itEnd && (*it)->canBind(); ++it) { (*it)->bind(pos); diff --git a/Data/ODBC/src/TypeInfo.cpp b/Data/ODBC/src/TypeInfo.cpp index 8432a639e..f9f1cf735 100644 --- a/Data/ODBC/src/TypeInfo.cpp +++ b/Data/ODBC/src/TypeInfo.cpp @@ -202,7 +202,7 @@ DynamicAny TypeInfo::getInfo(SQLSMALLINT type, const std::string& param) const } -bool TypeInfo::getSafeInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const +bool TypeInfo::tryGetInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const { TypeInfoVec::const_iterator it = _typeInfo.begin(); TypeInfoVec::const_iterator end = _typeInfo.end();