Skip to content

Commit 40c0f41

Browse files
committed
improved ODBC error reporting (SQL_NO_DATA)
1 parent 2fa2a98 commit 40c0f41

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎Data/ODBC/src/ODBCStatementImpl.cpp‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// ODBCStatementImpl.cpp
33
//
4-
// $Id: //poco/Main/Data/ODBC/src/ODBCStatementImpl.cpp#5 $
4+
// $Id: //poco/Main/Data/ODBC/src/ODBCStatementImpl.cpp#8 $
55
//
66
// Library: ODBC
77
// Package: ODBC
@@ -323,12 +323,16 @@ void ODBCStatementImpl::checkError(SQLRETURN rc, const std::string& msg)
323323
{
324324
if (Utility::isError(rc))
325325
{
326-
std::ostringstream os;
327-
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
328-
os << "Native SQL statement: " << nativeSQL() << std::endl;
329-
std::string str(msg); str += os.str();
330-
331-
throw StatementException(_stmt, str);
326+
if (rc != SQL_NO_DATA)
327+
{
328+
std::ostringstream os;
329+
os << std::endl << "Requested SQL statement: " << toString() << std::endl;
330+
os << "Native SQL statement: " << nativeSQL() << std::endl;
331+
std::string str(msg); str += os.str();
332+
333+
throw StatementException(_stmt, str);
334+
}
335+
else throw NoDataException();
332336
}
333337
}
334338

‎Data/include/Poco/Data/DataException.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DataException.h
33
//
4-
// $Id: //poco/Main/Data/include/Poco/Data/DataException.h#7 $
4+
// $Id: //poco/Main/Data/include/Poco/Data/DataException.h#8 $
55
//
66
// Library: Data
77
// Package: DataCore
@@ -60,6 +60,7 @@ POCO_DECLARE_EXCEPTION(Data_API, NotSupportedException, DataException)
6060
POCO_DECLARE_EXCEPTION(Data_API, NotImplementedException, DataException)
6161
POCO_DECLARE_EXCEPTION(Data_API, SessionUnavailableException, DataException)
6262
POCO_DECLARE_EXCEPTION(Data_API, SessionPoolExhaustedException, DataException)
63+
POCO_DECLARE_EXCEPTION(Data_API, NoDataException, DataException)
6364

6465

6566
} } // namespace Poco::Data

‎Data/src/DataException.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DataException.cpp
33
//
4-
// $Id: //poco/Main/Data/src/DataException.cpp#7 $
4+
// $Id: //poco/Main/Data/src/DataException.cpp#8 $
55
//
66
// Library: Data
77
// Package: DataCore
@@ -54,6 +54,7 @@ POCO_IMPLEMENT_EXCEPTION(NotSupportedException, DataException, "Feature or prope
5454
POCO_IMPLEMENT_EXCEPTION(NotImplementedException, DataException, "Feature or property not implemented")
5555
POCO_IMPLEMENT_EXCEPTION(SessionUnavailableException, DataException, "Session is unavailable")
5656
POCO_IMPLEMENT_EXCEPTION(SessionPoolExhaustedException, DataException, "No more sessions available from the session pool")
57+
POCO_IMPLEMENT_EXCEPTION(NoDataException, DataException, "No data found")
5758

5859

5960
} } // namespace Poco::Data

0 commit comments

Comments
 (0)