diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-19 19:50:31 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-09-19 20:37:54 +0100 |
commit | 52841daec985e04bff77ee6eb1d70af0238e0eae (patch) | |
tree | b299c2734c9dbc764f564dcd3fe00371c23f81ff /connectivity | |
parent | a11b6d5356f191f1d4d7ce48e80ce3f2534dc190 (diff) |
Throw sane exception when wrong type used in PreparedStatement.
Change-Id: Ie9577ed021930c56f3270aa30306d89365c1b3b1
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index d1261d441a6a..574bc06bb810 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -222,12 +222,13 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, case SQL_TEXT: memcpy(pVar->sqldata, str.getStr(), str.getLength()); // Fill remainder with spaces - // TODO: would 0 be better here for filling? memset(pVar->sqldata + str.getLength(), ' ', pVar->sqllen - str.getLength()); break; default: - // TODO: sane error message - throw SQLException(); + ::dbtools::throwSQLException( + "Incorrect type for setString", + ::dbtools::SQL_INVALID_SQL_DATA_TYPE, + *this); } } @@ -341,7 +342,12 @@ void OPreparedStatement::setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType) XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1); if ((pVar->sqltype & ~1) != nType) - throw SQLException(); // TODO: cast instead? + { + ::dbtools::throwSQLException( + "Incorrect type for setString", + ::dbtools::SQL_INVALID_SQL_DATA_TYPE, + *this); + } memcpy(pVar->sqldata, &nValue, sizeof(nValue)); } |