summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-01-18 13:10:12 +0100
committerPetr Mladek <pmladek@suse.cz>2012-08-06 18:13:26 +0200
commit7f75bc39fc1f49fe0b8c5c550eb801c0974a53a2 (patch)
tree8e11af8f3abf37935493ec03e7f85c2e769a105c
parentc26e0a21097f75c95e6e7ac317a0c3a8db9f4fe6 (diff)
OKeySet: tryRefetch and refreshRow share most of their code
Signed-off-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r--dbaccess/source/core/api/KeySet.cxx80
-rw-r--r--dbaccess/source/core/api/KeySet.hxx1
2 files changed, 26 insertions, 55 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 44c17d8a85af..4cad58a9f006 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -881,45 +881,9 @@ void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch)
{
if ( bRefetch )
{
- // we just areassign the base members
try
{
- Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
- OSL_ENSURE(xParameter.is(),"No Parameter interface!");
- xParameter->clearParameters();
-
- sal_Int32 nPos=1;
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaIter;
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaEnd;
- OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
- if ( aUpdateFind == m_aUpdatedParameter.end() )
- {
- aParaIter = m_aParameterValueForCache.get().begin();
- aParaEnd = m_aParameterValueForCache.get().end();
- }
- else
- {
- aParaIter = aUpdateFind->second.get().begin();
- aParaEnd = aUpdateFind->second.get().end();
- }
-
- for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
- {
- ::dbtools::setObjectWithInfo( xParameter, nPos, aParaIter->makeAny(), aParaIter->getTypeKind() );
- }
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aIter2 = m_aKeyIter->second.first->get().begin();
- SelectColumnsMetaData::const_iterator aPosIter = (*m_pKeyColumnNames).begin();
- SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end();
- for(;aPosIter != aPosEnd;++aPosIter,++aIter2)
- setOneKeyColumnParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
- aPosIter = (*m_pForeignColumnNames).begin();
- aPosEnd = (*m_pForeignColumnNames).end();
- for(;aPosIter != aPosEnd;++aPosIter,++aIter2)
- setOneKeyColumnParameter(nPos,xParameter,*aIter2,aPosIter->second.nType,aPosIter->second.nScale);
-
- m_xSet = m_xStatement->executeQuery();
- OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
- bRefetch = m_xSet->next();
+ bRefetch = doTryRefetch_throw();
}
catch(const Exception&)
{
@@ -1318,22 +1282,9 @@ sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException)
return previous_checked(sal_True);
}
-// -----------------------------------------------------------------------------
-void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
+bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException)
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" );
- if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
- return;
-
- m_xRow = NULL;
- ::comphelper::disposeComponent(m_xSet);
-
- if ( m_aKeyIter->second.second.second.is() )
- {
- m_xRow = m_aKeyIter->second.second.second;
- return;
- }
- // we just areassign the base members
+ // we just reassign the base members
Reference< XParameters > xParameter(m_xStatement,UNO_QUERY);
OSL_ENSURE(xParameter.is(),"No Parameter interface!");
xParameter->clearParameters();
@@ -1370,8 +1321,27 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
setOneKeyColumnParameter(nPos,xParameter,*aIter,aPosIter->second.nType,aPosIter->second.nScale);
m_xSet = m_xStatement->executeQuery();
- OSL_ENSURE(m_xSet.is(),"No resultset form statement!");
- sal_Bool bOK = m_xSet->next();
+ OSL_ENSURE(m_xSet.is(),"No resultset from statement!");
+ return m_xSet->next();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::refreshRow" );
+ if(isBeforeFirst() || isAfterLast() || !m_xStatement.is())
+ return;
+
+ m_xRow = NULL;
+ ::comphelper::disposeComponent(m_xSet);
+
+ if ( m_aKeyIter->second.second.second.is() )
+ {
+ m_xRow = m_aKeyIter->second.second.second;
+ return;
+ }
+
+ sal_Bool bOK = doTryRefetch_throw();
if ( !bOK )
{
// This row has disappeared; remove it.
@@ -1396,7 +1366,7 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException)
else
{
m_xRow.set(m_xSet,UNO_QUERY);
- OSL_ENSURE(m_xRow.is(),"No row form statement!");
+ OSL_ENSURE(m_xRow.is(),"No row from statement!");
}
}
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 196f1590354d..90ba03362690 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -149,6 +149,7 @@ namespace dbaccess
sal_Int32 _nType,
sal_Int32 _nScale ) const;
::rtl::OUStringBuffer createKeyFilter();
+ bool doTryRefetch_throw() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);;
void tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch);
void executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions = ::std::vector<sal_Int32>());
void executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName = ::rtl::OUString(),bool bRefetch = false);