improved ODBC error reporting (SQL_NO_DATA)

This commit is contained in:
Guenter Obiltschnig
2007-09-19 20:01:48 +00:00
parent 2fa2a98714
commit 40c0f41fa0
3 changed files with 15 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
//
// ODBCStatementImpl.cpp
//
// $Id: //poco/Main/Data/ODBC/src/ODBCStatementImpl.cpp#5 $
// $Id: //poco/Main/Data/ODBC/src/ODBCStatementImpl.cpp#8 $
//
// Library: ODBC
// Package: ODBC
@@ -323,12 +323,16 @@ void ODBCStatementImpl::checkError(SQLRETURN rc, const std::string& msg)
{
if (Utility::isError(rc))
{
std::ostringstream os;
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
os << "Native SQL statement: " << nativeSQL() << std::endl;
std::string str(msg); str += os.str();
if (rc != SQL_NO_DATA)
{
std::ostringstream os;
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
os << "Native SQL statement: " << nativeSQL() << std::endl;
std::string str(msg); str += os.str();
throw StatementException(_stmt, str);
throw StatementException(_stmt, str);
}
else throw NoDataException();
}
}

View File

@@ -1,7 +1,7 @@
//
// DataException.h
//
// $Id: //poco/Main/Data/include/Poco/Data/DataException.h#7 $
// $Id: //poco/Main/Data/include/Poco/Data/DataException.h#8 $
//
// Library: Data
// Package: DataCore
@@ -60,6 +60,7 @@ POCO_DECLARE_EXCEPTION(Data_API, NotSupportedException, DataException)
POCO_DECLARE_EXCEPTION(Data_API, NotImplementedException, DataException)
POCO_DECLARE_EXCEPTION(Data_API, SessionUnavailableException, DataException)
POCO_DECLARE_EXCEPTION(Data_API, SessionPoolExhaustedException, DataException)
POCO_DECLARE_EXCEPTION(Data_API, NoDataException, DataException)
} } // namespace Poco::Data

View File

@@ -1,7 +1,7 @@
//
// DataException.cpp
//
// $Id: //poco/Main/Data/src/DataException.cpp#7 $
// $Id: //poco/Main/Data/src/DataException.cpp#8 $
//
// Library: Data
// Package: DataCore
@@ -54,6 +54,7 @@ POCO_IMPLEMENT_EXCEPTION(NotSupportedException, DataException, "Feature or prope
POCO_IMPLEMENT_EXCEPTION(NotImplementedException, DataException, "Feature or property not implemented")
POCO_IMPLEMENT_EXCEPTION(SessionUnavailableException, DataException, "Session is unavailable")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExhaustedException, DataException, "No more sessions available from the session pool")
POCO_IMPLEMENT_EXCEPTION(NoDataException, DataException, "No data found")
} } // namespace Poco::Data