reduced exception throwing

This commit is contained in:
Peter Schojer
2008-07-09 08:51:19 +00:00
parent 693db42cee
commit e7ce0a5b52
3 changed files with 34 additions and 5 deletions

View File

@@ -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)

View File

@@ -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
{

View File

@@ -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);