diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2012-01-18 13:10:12 +0100 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2012-01-18 13:13:59 +0100 |
commit | 773668c6ab0963f56f98270b29d595f5df7c4bb2 (patch) | |
tree | b1a7d93bf4f8c1251d6a2674fd37a09f6db86fa7 /dbaccess/source | |
parent | c2567a658735423948d76992ca744a4187620928 (diff) |
OKeySet: tryRefetch and refreshRow share most of their code
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 80 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 1 |
2 files changed, 26 insertions, 55 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 46444e935d0f..d55f075c04ac 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&) { @@ -1327,22 +1291,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(); @@ -1379,8 +1330,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 ) { OKeySetMatrix::iterator aTemp = m_aKeyIter; @@ -1392,7 +1362,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); |