mirror of
https://github.com/pocoproject/poco.git
synced 2026-01-11 00:24:15 +01:00
reduced exception throwing
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user