diff options
author | Kurt Zenker <kz@openoffice.org> | 2006-07-06 13:19:48 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2006-07-06 13:19:48 +0000 |
commit | 3ffb7ecd98c8cd7c1748ba27a89b8f7c664cc841 (patch) | |
tree | 1c34e850705d698bbaf38c7446ee423c21479fdd | |
parent | 7487899b36536b1779ea5a56881d93237743be50 (diff) |
INTEGRATION: CWS kabparam (1.3.8); FILE MERGED
2006/06/29 08:15:22 ebischoff 1.3.8.1: #i66691# Support for parametrized queries in KDE address book connector
-rw-r--r-- | connectivity/source/drivers/kab/KPreparedStatement.cxx | 64 | ||||
-rw-r--r-- | connectivity/source/drivers/kab/KResultSet.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/kab/KResultSet.hxx | 8 |
3 files changed, 65 insertions, 16 deletions
diff --git a/connectivity/source/drivers/kab/KPreparedStatement.cxx b/connectivity/source/drivers/kab/KPreparedStatement.cxx index cb634bb11a00..a5936b8269c8 100644 --- a/connectivity/source/drivers/kab/KPreparedStatement.cxx +++ b/connectivity/source/drivers/kab/KPreparedStatement.cxx @@ -4,9 +4,9 @@ * * $RCSfile: KPreparedStatement.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2006-06-20 01:38:53 $ + * last change: $Author: kz $ $Date: 2006-07-06 14:17:26 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -50,10 +50,19 @@ using namespace com::sun::star::util; IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement"); // ------------------------------------------------------------------------- -void KabPreparedStatement::checkParameterIndex(sal_Int32) +void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) throw(SQLException) { - // no parameters allowed in this implementation - throw SQLException(); + if ( !m_aParameterRow.isValid() ) + m_aParameterRow = new OValueVector(); + + if (nParams < 1) + ::dbtools::throwSQLException( + "SQL statement parameters are numbered starting at 1.", + ::dbtools::SQL_INVALID_DESCRIPTOR_INDEX, + *(KabPreparedStatement *) this); + + if (nParams >= (sal_Int32) (*m_aParameterRow).size()) + (*m_aParameterRow).resize(nParams); } // ------------------------------------------------------------------------- void KabPreparedStatement::setKabFields() const throw(SQLException) @@ -70,12 +79,32 @@ void KabPreparedStatement::setKabFields() const throw(SQLException) m_xMetaData->setKabFields(xColumns); } // ------------------------------------------------------------------------- +void KabPreparedStatement::resetParameters() const throw(SQLException) +{ + m_nParameterIndex = 0; +} +// ------------------------------------------------------------------------- +void KabPreparedStatement::getNextParameter(::rtl::OUString &rParameter) const throw(SQLException) +{ + if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size()) + ::dbtools::throwSQLException( + "More parameters in SQL statement than set.", + ::dbtools::SQL_INVALID_DESCRIPTOR_INDEX, + *(KabPreparedStatement *) this); + + rParameter = (*m_aParameterRow)[m_nParameterIndex]; + + m_nParameterIndex++; +} +// ------------------------------------------------------------------------- KabPreparedStatement::KabPreparedStatement( KabConnection* _pConnection, const ::rtl::OUString& sql) : KabPreparedStatement_BASE(_pConnection), m_sSqlStatement(sql), - m_bPrepared(sal_False) + m_bPrepared(sal_False), + m_nParameterIndex(0), + m_aParameterRow() { } // ------------------------------------------------------------------------- @@ -83,6 +112,17 @@ KabPreparedStatement::~KabPreparedStatement() { } // ------------------------------------------------------------------------- +void KabPreparedStatement::disposing() +{ + KabPreparedStatement_BASE::disposing(); + + if (m_aParameterRow.isValid()) + { + m_aParameterRow->clear(); + m_aParameterRow = NULL; + } +} +// ------------------------------------------------------------------------- Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData() throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -152,12 +192,14 @@ Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery() throw(SQLE return rs; } // ------------------------------------------------------------------------- -void SAL_CALL KabPreparedStatement::setNull(sal_Int32, sal_Int32) throw(SQLException, RuntimeException) +void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedException(::rtl::OUString::createFromAscii("Not Implemented"), NULL); + checkAndResizeParameters(parameterIndex); + + (*m_aParameterRow)[parameterIndex - 1].setNull(); } // ------------------------------------------------------------------------- void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException) @@ -224,12 +266,14 @@ void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double) throw(SQLExcept ::dbtools::throwFunctionNotSupportedException(::rtl::OUString::createFromAscii("Not Implemented"), NULL); } // ------------------------------------------------------------------------- -void SAL_CALL KabPreparedStatement::setString(sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException) +void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const ::rtl::OUString &x) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed); -::dbtools::throwFunctionNotSupportedException(::rtl::OUString::createFromAscii("Not Implemented"), NULL); + checkAndResizeParameters(parameterIndex); + + (*m_aParameterRow)[parameterIndex - 1] = x; } // ------------------------------------------------------------------------- void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx index da6c2c1c2198..0e99713f4c3a 100644 --- a/connectivity/source/drivers/kab/KResultSet.cxx +++ b/connectivity/source/drivers/kab/KResultSet.cxx @@ -4,9 +4,9 @@ * * $RCSfile: KResultSet.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2006-06-20 01:39:09 $ + * last change: $Author: kz $ $Date: 2006-07-06 14:19:01 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -49,7 +49,10 @@ #ifndef _CONNECTIVITY_KAB_FIELDS_HXX_ #include "kfields.hxx" #endif -#include "kabc_addressbook.hxx" + +#define KDE_HEADERS_WANT_KABC_ADDRESSBOOK +#include "kde_headers.hxx" + #include <qdatetime.h> #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ diff --git a/connectivity/source/drivers/kab/KResultSet.hxx b/connectivity/source/drivers/kab/KResultSet.hxx index 63385b2c20ed..e079689a5b9f 100644 --- a/connectivity/source/drivers/kab/KResultSet.hxx +++ b/connectivity/source/drivers/kab/KResultSet.hxx @@ -4,9 +4,9 @@ * * $RCSfile: KResultSet.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hr $ $Date: 2006-06-20 01:39:24 $ + * last change: $Author: kz $ $Date: 2006-07-06 14:19:48 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -42,7 +42,9 @@ #ifndef _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_ #include "KResultSetMetaData.hxx" #endif -#include <kabc/addressee.h> + +#define KDE_HEADERS_WANT_KABC_ADDRESSEE +#include "kde_headers.hxx" #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> |