summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-27 20:35:33 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-27 20:58:31 +0100
commit8620524f1979105c35460ad7cf621468b7ef6a28 (patch)
treea5daf8ab302b109876dd2c3ec0606876a43603f4 /connectivity
parentdadba3efcb2fb3df3b89058dfd4a98d648241ec6 (diff)
Implement setShort. (firebird-sdbc)
Change-Id: Ia543f34344915c4621ba0c6ce6984dce7ca9e08b
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.cxx50
1 files changed, 32 insertions, 18 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 1898777a814e..004d191a15c1 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -24,6 +24,7 @@
#include "Util.hxx"
#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <osl/diagnose.h>
#include <propertyids.hxx>
@@ -320,25 +321,48 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery()
return m_xResultSet;
}
-// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+//----- XParameters -----------------------------------------------------------
+void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 nIndex, sal_Bool x)
+ throw(SQLException, RuntimeException)
{
- (void) parameterIndex;
+ (void) nIndex;
(void) x;
- ::osl::MutexGuard aGuard( m_pConnection->getMutex() );
+ MutexGuard aGuard(m_pConnection->getMutex());
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
+ // TODO: decide how to deal with bools. Probably just as a byte, although
+ // it might be best to just determine the db type and set as appropriate?
}
-// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+
+void SAL_CALL OPreparedStatement::setByte(sal_Int32 nIndex, sal_Int8 x)
+ throw(SQLException, RuntimeException)
{
- (void) parameterIndex;
+ (void) nIndex;
(void) x;
- ::osl::MutexGuard aGuard( m_pConnection->getMutex() );
+ ::dbtools::throwFunctionNotSupportedException("setByte not supported in firebird",
+ *this,
+ Any());
+}
+
+void SAL_CALL OPreparedStatement::setShort(sal_Int32 nIndex, sal_Int16 x)
+ throw(SQLException, RuntimeException)
+{
+ MutexGuard aGuard( m_pConnection->getMutex() );
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
+ ensurePrepared();
+
+ checkParameterIndex(nIndex);
+ setParameterNull(nIndex, false);
+ XSQLVAR* pVar = m_pInSqlda->sqlvar + (nIndex - 1);
+
+ int dtype = (pVar->sqltype & ~1); // drop flag bit for now
+ if (dtype != SQL_SHORT)
+ throw SQLException(); // TODO: cast instead?
+
+ memcpy(pVar->sqldata, &x, 2);
}
// -------------------------------------------------------------------------
@@ -497,16 +521,6 @@ void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
-{
- (void) parameterIndex;
- (void) x;
- ::osl::MutexGuard aGuard( m_pConnection->getMutex() );
- checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
-
-}
-// -------------------------------------------------------------------------
-
void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
{
(void) parameterIndex;