diff --git a/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h b/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h index a10531580..4f76a73c3 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h +++ b/Data/ODBC/include/Poco/Data/ODBC/TypeInfo.h @@ -110,6 +110,13 @@ 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 + + bool getSafeInfo(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. + void print(std::ostream& ostr); /// Prints all the types (as reported by the underlying database) diff --git a/Data/ODBC/src/Binder.cpp b/Data/ODBC/src/Binder.cpp index dd1832c47..a2ada694d 100644 --- a/Data/ODBC/src/Binder.cpp +++ b/Data/ODBC/src/Binder.cpp @@ -435,15 +435,20 @@ void Binder::getColSizeAndPrecision(std::size_t pos, { // Not all drivers are equally willing to cooperate in this matter. // Hence the funky flow control. - try + DynamicAny tmp; + bool found(false); + if (_pTypeInfo) { - if (_pTypeInfo) + found = _pTypeInfo->getSafeInfo(cDataType, "COLUMN_SIZE", tmp); + if (found) + colSize = tmp; + found = _pTypeInfo->getSafeInfo(cDataType, "MINIMUM_SCALE", tmp); + if (found) { - colSize = _pTypeInfo->getInfo(cDataType, "COLUMN_SIZE"); - decDigits = _pTypeInfo->getInfo(cDataType, "MINIMUM_SCALE"); + decDigits = tmp; return; } - } catch (NotFoundException&) { } + } try { diff --git a/Data/ODBC/src/TypeInfo.cpp b/Data/ODBC/src/TypeInfo.cpp index d38942ba3..8432a639e 100644 --- a/Data/ODBC/src/TypeInfo.cpp +++ b/Data/ODBC/src/TypeInfo.cpp @@ -202,6 +202,23 @@ DynamicAny TypeInfo::getInfo(SQLSMALLINT type, const std::string& param) const } +bool TypeInfo::getSafeInfo(SQLSMALLINT type, const std::string& param, DynamicAny& result) const +{ + TypeInfoVec::const_iterator it = _typeInfo.begin(); + TypeInfoVec::const_iterator end = _typeInfo.end(); + for (; it != end; ++it) + { + if (type == it->get<1>()) + { + result = (*it)[param]; + return true; + } + } + + return false; +} + + int TypeInfo::cDataType(int sqlDataType) const { DataTypeMap::const_iterator it = _cDataTypes.find(sqlDataType);