1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir #include <limits> // included here to prevent problems if compiling with C52 27cdf0e10cSrcweir 28cdf0e10cSrcweir #ifdef GCC 29cdf0e10cSrcweir #include <iostream> 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include "connectivity/sdbcx/VColumn.hxx" 32cdf0e10cSrcweir #include "file/FResultSet.hxx" 33cdf0e10cSrcweir #include "file/FResultSetMetaData.hxx" 34cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 35cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 36cdf0e10cSrcweir #include <comphelper/property.hxx> 37cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 39cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp> 40cdf0e10cSrcweir #include <comphelper/sequence.hxx> 41cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 42cdf0e10cSrcweir #include "connectivity/dbconversion.hxx" 43cdf0e10cSrcweir #include "connectivity/dbtools.hxx" 44cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx> 45cdf0e10cSrcweir #include <iterator> 46cdf0e10cSrcweir #include <tools/debug.hxx> 47cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp> 48cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp> 49cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp> 50cdf0e10cSrcweir #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include <algorithm> 53cdf0e10cSrcweir #include <comphelper/extract.hxx> 54cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 55cdf0e10cSrcweir #include <comphelper/types.hxx> 56cdf0e10cSrcweir #include "resource/file_res.hrc" 57cdf0e10cSrcweir #include "resource/sharedresources.hxx" 58cdf0e10cSrcweir #include <rtl/logfile.hxx> 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir using namespace ::comphelper; 62cdf0e10cSrcweir using namespace connectivity; 63cdf0e10cSrcweir using namespace connectivity::file; 64cdf0e10cSrcweir using namespace ::cppu; 65cdf0e10cSrcweir using namespace dbtools; 66cdf0e10cSrcweir using namespace com::sun::star::uno; 67cdf0e10cSrcweir using namespace com::sun::star::lang; 68cdf0e10cSrcweir using namespace com::sun::star::beans; 69cdf0e10cSrcweir using namespace com::sun::star::sdbc; 70cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 71cdf0e10cSrcweir using namespace com::sun::star::container; 72cdf0e10cSrcweir 73cdf0e10cSrcweir // Maximale Anzahl von Rows, die mit ORDER BY sortiert durchlaufen werden koennen: 74cdf0e10cSrcweir #define MAX_KEYSET_SIZE 0x40000 // 256K 75cdf0e10cSrcweir 76cdf0e10cSrcweir namespace 77cdf0e10cSrcweir { 78cdf0e10cSrcweir void lcl_throwError(sal_uInt16 _nErrorId,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xContext) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir ::connectivity::SharedResources aResources; 81cdf0e10cSrcweir const ::rtl::OUString sMessage = aResources.getResourceString(_nErrorId); 82cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sMessage ,_xContext); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir } 85cdf0e10cSrcweir //------------------------------------------------------------------------------ 86cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet"); 87cdf0e10cSrcweir DBG_NAME( file_OResultSet ) 88cdf0e10cSrcweir // ------------------------------------------------------------------------- 89cdf0e10cSrcweir OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex) 90cdf0e10cSrcweir ,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper) 91cdf0e10cSrcweir ,m_aAssignValues(NULL) 92cdf0e10cSrcweir ,m_pEvaluationKeySet(NULL) 93cdf0e10cSrcweir ,m_aSkipDeletedSet(this) 94cdf0e10cSrcweir ,m_pFileSet(NULL) 95cdf0e10cSrcweir ,m_pSortIndex(NULL) 96cdf0e10cSrcweir ,m_pTable(NULL) 97cdf0e10cSrcweir ,m_pParseTree(pStmt->getParseTree()) 98cdf0e10cSrcweir ,m_pSQLAnalyzer(NULL) 99cdf0e10cSrcweir ,m_aSQLIterator(_aSQLIterator) 100cdf0e10cSrcweir ,m_nFetchSize(0) 101cdf0e10cSrcweir ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE) 102cdf0e10cSrcweir ,m_nFetchDirection(FetchDirection::FORWARD) 103cdf0e10cSrcweir ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) 104cdf0e10cSrcweir ,m_xStatement(*pStmt) 105cdf0e10cSrcweir ,m_xMetaData(NULL) 106cdf0e10cSrcweir ,m_xDBMetaData(pStmt->getOwnConnection()->getMetaData()) 107cdf0e10cSrcweir ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding()) 108cdf0e10cSrcweir ,m_nRowPos(-1) 109cdf0e10cSrcweir ,m_nFilePos(0) 110cdf0e10cSrcweir ,m_nLastVisitedPos(-1) 111cdf0e10cSrcweir ,m_nRowCountResult(-1) 112cdf0e10cSrcweir ,m_nCurrentPosition(0) 113cdf0e10cSrcweir ,m_nColumnCount(0) 114cdf0e10cSrcweir ,m_bWasNull(sal_False) 115cdf0e10cSrcweir ,m_bEOF(sal_False) 116cdf0e10cSrcweir ,m_bLastRecord(sal_False) 117cdf0e10cSrcweir ,m_bInserted(sal_False) 118cdf0e10cSrcweir ,m_bRowUpdated(sal_False) 119cdf0e10cSrcweir ,m_bRowInserted(sal_False) 120cdf0e10cSrcweir ,m_bRowDeleted(sal_False) 121cdf0e10cSrcweir ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted()) 122cdf0e10cSrcweir ,m_bIsCount(sal_False) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" ); 125cdf0e10cSrcweir DBG_CTOR( file_OResultSet, NULL ); 126cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 127cdf0e10cSrcweir m_bIsCount = (m_pParseTree && 128cdf0e10cSrcweir m_pParseTree->count() > 2 && 129cdf0e10cSrcweir SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) && 130cdf0e10cSrcweir SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) && 131cdf0e10cSrcweir SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) && 132cdf0e10cSrcweir m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4 133cdf0e10cSrcweir ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE; 136cdf0e10cSrcweir construct(); 137cdf0e10cSrcweir m_aSkipDeletedSet.SetDeletedVisible(m_bShowDeleted); 138cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir // ------------------------------------------------------------------------- 142cdf0e10cSrcweir OResultSet::~OResultSet() 143cdf0e10cSrcweir { 144cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::~OResultSet" ); 145cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 146cdf0e10cSrcweir disposing(); 147cdf0e10cSrcweir DBG_DTOR( file_OResultSet, NULL ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir // ------------------------------------------------------------------------- 150cdf0e10cSrcweir void OResultSet::construct() 151cdf0e10cSrcweir { 152cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::construct" ); 153cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 154cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 155cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 156cdf0e10cSrcweir registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir // ------------------------------------------------------------------------- 159cdf0e10cSrcweir void OResultSet::disposing(void) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" ); 162cdf0e10cSrcweir OPropertySetHelper::disposing(); 163cdf0e10cSrcweir 164cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 165cdf0e10cSrcweir m_xStatement.clear(); 166cdf0e10cSrcweir m_xMetaData.clear(); 167cdf0e10cSrcweir m_pParseTree = NULL; 168cdf0e10cSrcweir m_xColNames.clear(); 169cdf0e10cSrcweir m_xColumns = NULL; 170cdf0e10cSrcweir m_xParamColumns = NULL; 171cdf0e10cSrcweir m_xColsIdx.clear(); 172cdf0e10cSrcweir 173cdf0e10cSrcweir Reference<XComponent> xComp = m_pTable; 174cdf0e10cSrcweir if ( xComp.is() ) 175cdf0e10cSrcweir xComp->removeEventListener(this); 176cdf0e10cSrcweir if(m_pTable) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir m_pTable->release(); 179cdf0e10cSrcweir m_pTable = NULL; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir clear(); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir // ----------------------------------------------------------------------------- 184cdf0e10cSrcweir void OResultSet::clear() 185cdf0e10cSrcweir { 186cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clear" ); 187cdf0e10cSrcweir m_pFileSet = NULL; 188cdf0e10cSrcweir DELETEZ(m_pSortIndex); 189cdf0e10cSrcweir 190cdf0e10cSrcweir if(m_aInsertRow.isValid()) 191cdf0e10cSrcweir m_aInsertRow->get().clear(); 192cdf0e10cSrcweir 193cdf0e10cSrcweir m_aSkipDeletedSet.clear(); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir // ------------------------------------------------------------------------- 196cdf0e10cSrcweir Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" ); 199cdf0e10cSrcweir Any aRet = OPropertySetHelper::queryInterface(rType); 200cdf0e10cSrcweir return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir // ------------------------------------------------------------------------- 203cdf0e10cSrcweir Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw(RuntimeException) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTypes" ); 206cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ), 209cdf0e10cSrcweir ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ), 210cdf0e10cSrcweir ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 )); 211cdf0e10cSrcweir 212cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes()); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir // ------------------------------------------------------------------------- 215cdf0e10cSrcweir 216cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::findColumn" ); 219cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 220cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir Reference< XResultSetMetaData > xMeta = getMetaData(); 224cdf0e10cSrcweir sal_Int32 nLen = xMeta->getColumnCount(); 225cdf0e10cSrcweir sal_Int32 i = 1; 226cdf0e10cSrcweir for(;i<=nLen;++i) 227cdf0e10cSrcweir if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : 228cdf0e10cSrcweir columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i))) 229cdf0e10cSrcweir break; 230cdf0e10cSrcweir return i; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir // ----------------------------------------------------------------------------- 233cdf0e10cSrcweir const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getValue" ); 236cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 237cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 238cdf0e10cSrcweir 239cdf0e10cSrcweir //columnIndex = mapColumn(columnIndex); 240cdf0e10cSrcweir checkIndex(columnIndex ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir 243cdf0e10cSrcweir m_bWasNull = (m_aSelectRow->get())[columnIndex]->getValue().isNull(); 244cdf0e10cSrcweir return *(m_aSelectRow->get())[columnIndex]; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir // ----------------------------------------------------------------------------- 247cdf0e10cSrcweir void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::checkIndex" ); 250cdf0e10cSrcweir if ( columnIndex <= 0 251cdf0e10cSrcweir // || columnIndex > (sal_Int32)m_xColumns->size() 252cdf0e10cSrcweir || columnIndex >= m_nColumnCount ) 253cdf0e10cSrcweir ::dbtools::throwInvalidIndexException(*this); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir // ------------------------------------------------------------------------- 256cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" ); 259cdf0e10cSrcweir return NULL; 260cdf0e10cSrcweir } 261cdf0e10cSrcweir // ------------------------------------------------------------------------- 262cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" ); 265cdf0e10cSrcweir return NULL; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir // ------------------------------------------------------------------------- 269cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" ); 272cdf0e10cSrcweir return getValue(columnIndex); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir // ------------------------------------------------------------------------- 275cdf0e10cSrcweir 276cdf0e10cSrcweir sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getByte" ); 279cdf0e10cSrcweir return getValue(columnIndex); 280cdf0e10cSrcweir } 281cdf0e10cSrcweir // ------------------------------------------------------------------------- 282cdf0e10cSrcweir 283cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBytes" ); 286cdf0e10cSrcweir return getValue(columnIndex); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir // ------------------------------------------------------------------------- 289cdf0e10cSrcweir 290cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDate" ); 293cdf0e10cSrcweir return getValue(columnIndex); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir // ------------------------------------------------------------------------- 296cdf0e10cSrcweir 297cdf0e10cSrcweir double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDouble" ); 300cdf0e10cSrcweir return getValue(columnIndex); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir // ------------------------------------------------------------------------- 303cdf0e10cSrcweir 304cdf0e10cSrcweir float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getFloat" ); 307cdf0e10cSrcweir return getValue(columnIndex); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir // ------------------------------------------------------------------------- 310cdf0e10cSrcweir 311cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInt" ); 314cdf0e10cSrcweir return getValue(columnIndex); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir // ------------------------------------------------------------------------- 317cdf0e10cSrcweir 318cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRow" ); 321cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 322cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 323cdf0e10cSrcweir 324cdf0e10cSrcweir OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row"); 325cdf0e10cSrcweir 326cdf0e10cSrcweir return m_aSkipDeletedSet.getMappedPosition((m_aRow->get())[0]->getValue()); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir // ------------------------------------------------------------------------- 329cdf0e10cSrcweir 330cdf0e10cSrcweir sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getLong" ); 333cdf0e10cSrcweir return getValue(columnIndex); 334cdf0e10cSrcweir } 335cdf0e10cSrcweir // ------------------------------------------------------------------------- 336cdf0e10cSrcweir 337cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" ); 340cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 341cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 342cdf0e10cSrcweir 343cdf0e10cSrcweir 344cdf0e10cSrcweir if(!m_xMetaData.is()) 345cdf0e10cSrcweir m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable); 346cdf0e10cSrcweir return m_xMetaData; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir // ------------------------------------------------------------------------- 349cdf0e10cSrcweir Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getArray" ); 352cdf0e10cSrcweir return NULL; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir // ------------------------------------------------------------------------- 356cdf0e10cSrcweir 357cdf0e10cSrcweir Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getClob" ); 360cdf0e10cSrcweir return NULL; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir // ------------------------------------------------------------------------- 363cdf0e10cSrcweir Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBlob" ); 366cdf0e10cSrcweir return NULL; 367cdf0e10cSrcweir } 368cdf0e10cSrcweir // ------------------------------------------------------------------------- 369cdf0e10cSrcweir 370cdf0e10cSrcweir Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRef" ); 373cdf0e10cSrcweir return NULL; 374cdf0e10cSrcweir } 375cdf0e10cSrcweir // ------------------------------------------------------------------------- 376cdf0e10cSrcweir 377cdf0e10cSrcweir Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getObject" ); 380cdf0e10cSrcweir return getValue(columnIndex).makeAny(); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir // ------------------------------------------------------------------------- 383cdf0e10cSrcweir 384cdf0e10cSrcweir sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getShort" ); 387cdf0e10cSrcweir return getValue(columnIndex); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir // ------------------------------------------------------------------------- 390cdf0e10cSrcweir ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getString" ); 393cdf0e10cSrcweir return getValue(columnIndex); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir // ------------------------------------------------------------------------- 396cdf0e10cSrcweir ::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTime" ); 399cdf0e10cSrcweir return getValue(columnIndex); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir // ------------------------------------------------------------------------- 402cdf0e10cSrcweir ::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" ); 405cdf0e10cSrcweir return getValue(columnIndex); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir // ------------------------------------------------------------------------- 408cdf0e10cSrcweir 409cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" ); 412cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 413cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 414cdf0e10cSrcweir 415cdf0e10cSrcweir 416cdf0e10cSrcweir return m_nRowPos == sal_Int32(m_pFileSet->get().size()); 417cdf0e10cSrcweir } 418cdf0e10cSrcweir // ------------------------------------------------------------------------- 419cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isFirst" ); 422cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 423cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 424cdf0e10cSrcweir 425cdf0e10cSrcweir 426cdf0e10cSrcweir return m_nRowPos == 0; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir // ------------------------------------------------------------------------- 429cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isLast" ); 432cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 433cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 434cdf0e10cSrcweir 435cdf0e10cSrcweir 436cdf0e10cSrcweir return m_nRowPos == sal_Int32(m_pFileSet->get().size() - 1); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir // ------------------------------------------------------------------------- 439cdf0e10cSrcweir void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" ); 442cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 443cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 444cdf0e10cSrcweir 445cdf0e10cSrcweir 446cdf0e10cSrcweir if(first()) 447cdf0e10cSrcweir previous(); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir // ------------------------------------------------------------------------- 450cdf0e10cSrcweir void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) 451cdf0e10cSrcweir { 452cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::afterLast" ); 453cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 454cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 455cdf0e10cSrcweir 456cdf0e10cSrcweir 457cdf0e10cSrcweir if(last()) 458cdf0e10cSrcweir next(); 459cdf0e10cSrcweir m_bEOF = sal_True; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir // ------------------------------------------------------------------------- 462cdf0e10cSrcweir 463cdf0e10cSrcweir void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::close" ); 466cdf0e10cSrcweir dispose(); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir // ------------------------------------------------------------------------- 469cdf0e10cSrcweir 470cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::first" ); 473cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 474cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 475cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,sal_True) : sal_False; 476cdf0e10cSrcweir } 477cdf0e10cSrcweir // ------------------------------------------------------------------------- 478cdf0e10cSrcweir 479cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::last" ); 482cdf0e10cSrcweir // here I know definitely that I stand on the last record 483cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 484cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 485cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_True) : sal_False; 486cdf0e10cSrcweir } 487cdf0e10cSrcweir // ------------------------------------------------------------------------- 488cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) 489cdf0e10cSrcweir { 490cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::absolute" ); 491cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 492cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 493cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE,row,sal_True) : sal_False; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir // ------------------------------------------------------------------------- 496cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::relative" ); 499cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 500cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 501cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE,row,sal_True) : sal_False; 502cdf0e10cSrcweir } 503cdf0e10cSrcweir // ------------------------------------------------------------------------- 504cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) 505cdf0e10cSrcweir { 506cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::previous" ); 507cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 508cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 509cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,sal_True) : sal_False; 510cdf0e10cSrcweir } 511cdf0e10cSrcweir // ------------------------------------------------------------------------- 512cdf0e10cSrcweir Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getStatement" ); 515cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 516cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 517cdf0e10cSrcweir 518cdf0e10cSrcweir 519cdf0e10cSrcweir return m_xStatement; 520cdf0e10cSrcweir } 521cdf0e10cSrcweir // ------------------------------------------------------------------------- 522cdf0e10cSrcweir 523cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" ); 526cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 527cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 528cdf0e10cSrcweir 529cdf0e10cSrcweir 530cdf0e10cSrcweir return m_bRowDeleted; 531cdf0e10cSrcweir } 532cdf0e10cSrcweir // ------------------------------------------------------------------------- 533cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException) 534cdf0e10cSrcweir { ::osl::MutexGuard aGuard( m_aMutex ); 535cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 536cdf0e10cSrcweir 537cdf0e10cSrcweir 538cdf0e10cSrcweir return m_bRowInserted; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir // ------------------------------------------------------------------------- 541cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" ); 544cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 545cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 546cdf0e10cSrcweir 547cdf0e10cSrcweir 548cdf0e10cSrcweir return m_bRowUpdated; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir // ------------------------------------------------------------------------- 551cdf0e10cSrcweir 552cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException) 553cdf0e10cSrcweir { 554cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" ); 555cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 556cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 557cdf0e10cSrcweir 558cdf0e10cSrcweir 559cdf0e10cSrcweir return m_nRowPos == -1; 560cdf0e10cSrcweir } 561cdf0e10cSrcweir // ------------------------------------------------------------------------- 562cdf0e10cSrcweir sal_Bool OResultSet::evaluate() 563cdf0e10cSrcweir { 564cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::evaluate" ); 565cdf0e10cSrcweir OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::evaluate: Analyzer isn't set!"); 566cdf0e10cSrcweir sal_Bool bRet = sal_True; 567cdf0e10cSrcweir while(!m_pSQLAnalyzer->evaluateRestriction()) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir if(m_pEvaluationKeySet) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir if(m_aEvaluateIter == m_pEvaluationKeySet->end()) 572cdf0e10cSrcweir return sal_False; 573cdf0e10cSrcweir bRet = m_pTable->seekRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),m_nRowPos); 574cdf0e10cSrcweir ++m_aEvaluateIter; 575cdf0e10cSrcweir } 576cdf0e10cSrcweir else 577cdf0e10cSrcweir bRet = m_pTable->seekRow(IResultSetHelper::NEXT,1,m_nRowPos); 578cdf0e10cSrcweir if(bRet) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir if(m_pEvaluationKeySet) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir bRet = m_pTable->fetchRow(m_aEvaluateRow,m_pTable->getTableColumns().getBody(),sal_True,sal_True); 583cdf0e10cSrcweir evaluate(); 584cdf0e10cSrcweir 585cdf0e10cSrcweir } 586cdf0e10cSrcweir else 587cdf0e10cSrcweir bRet = m_pTable->fetchRow(m_aRow,m_xColumns.getBody(),sal_False,sal_True); 588cdf0e10cSrcweir } 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir return bRet; 592cdf0e10cSrcweir } 593cdf0e10cSrcweir // ------------------------------------------------------------------------- 594cdf0e10cSrcweir 595cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::next" ); 598cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 599cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 600cdf0e10cSrcweir 601cdf0e10cSrcweir return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,sal_True) : sal_False; 602cdf0e10cSrcweir } 603cdf0e10cSrcweir // ------------------------------------------------------------------------- 604cdf0e10cSrcweir 605cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::wasNull" ); 608cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 609cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 610cdf0e10cSrcweir 611cdf0e10cSrcweir return m_bWasNull; 612cdf0e10cSrcweir } 613cdf0e10cSrcweir // ------------------------------------------------------------------------- 614cdf0e10cSrcweir 615cdf0e10cSrcweir void SAL_CALL OResultSet::cancel( ) throw(RuntimeException) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancel" ); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir // ------------------------------------------------------------------------- 620cdf0e10cSrcweir void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" ); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir // ------------------------------------------------------------------------- 625cdf0e10cSrcweir Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" ); 628cdf0e10cSrcweir return Any(); 629cdf0e10cSrcweir } 630cdf0e10cSrcweir // ------------------------------------------------------------------------- 631cdf0e10cSrcweir void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::insertRow" ); 634cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 635cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 636cdf0e10cSrcweir 637cdf0e10cSrcweir 638cdf0e10cSrcweir if(!m_bInserted || !m_pTable) 639cdf0e10cSrcweir throwFunctionSequenceException(*this); 640cdf0e10cSrcweir 641cdf0e10cSrcweir // we know that we append new rows at the end 642cdf0e10cSrcweir // so we have to know where the end is 643cdf0e10cSrcweir m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_False); 644cdf0e10cSrcweir m_bRowInserted = m_pTable->InsertRow(m_aInsertRow.getBody(), sal_True,m_xColsIdx); 645cdf0e10cSrcweir if(m_bRowInserted && m_pFileSet.isValid()) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir sal_Int32 nPos = (m_aInsertRow->get())[0]->getValue(); 648cdf0e10cSrcweir m_pFileSet->get().push_back(nPos); 649cdf0e10cSrcweir *(m_aInsertRow->get())[0] = sal_Int32(m_pFileSet->get().size()); 650cdf0e10cSrcweir clearInsertRow(); 651cdf0e10cSrcweir 652cdf0e10cSrcweir m_aSkipDeletedSet.insertNewPosition((m_aRow->get())[0]->getValue()); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir } 655cdf0e10cSrcweir // ------------------------------------------------------------------------- 656cdf0e10cSrcweir void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateRow" ); 659cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 660cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 661cdf0e10cSrcweir 662cdf0e10cSrcweir if(!m_pTable || m_pTable->isReadOnly()) 663cdf0e10cSrcweir lcl_throwError(STR_TABLE_READONLY,*this); 664cdf0e10cSrcweir 665cdf0e10cSrcweir m_bRowUpdated = m_pTable->UpdateRow(m_aInsertRow.getBody(), m_aRow,m_xColsIdx); 666cdf0e10cSrcweir *(m_aInsertRow->get())[0] = (sal_Int32)(m_aRow->get())[0]->getValue(); 667cdf0e10cSrcweir 668cdf0e10cSrcweir clearInsertRow(); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir // ------------------------------------------------------------------------- 671cdf0e10cSrcweir void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" ); 674cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 675cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 676cdf0e10cSrcweir 677cdf0e10cSrcweir 678cdf0e10cSrcweir if(!m_pTable || m_pTable->isReadOnly()) 679cdf0e10cSrcweir lcl_throwError(STR_TABLE_READONLY,*this); 680cdf0e10cSrcweir if (m_bShowDeleted) 681cdf0e10cSrcweir lcl_throwError(STR_DELETE_ROW,*this); 682cdf0e10cSrcweir if(m_aRow->isDeleted()) 683cdf0e10cSrcweir lcl_throwError(STR_ROW_ALREADY_DELETED,*this); 684cdf0e10cSrcweir 685cdf0e10cSrcweir sal_Int32 nPos = (sal_Int32)(m_aRow->get())[0]->getValue(); 686cdf0e10cSrcweir m_bRowDeleted = m_pTable->DeleteRow(m_xColumns.getBody()); 687cdf0e10cSrcweir if(m_bRowDeleted && m_pFileSet.isValid()) 688cdf0e10cSrcweir { 689cdf0e10cSrcweir m_aRow->setDeleted(sal_True); 690cdf0e10cSrcweir // don't touch the m_pFileSet member here 691cdf0e10cSrcweir m_aSkipDeletedSet.deletePosition(nPos); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir // ------------------------------------------------------------------------- 695cdf0e10cSrcweir void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" ); 698cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 699cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 700cdf0e10cSrcweir 701cdf0e10cSrcweir 702cdf0e10cSrcweir m_bInserted = sal_False; 703cdf0e10cSrcweir m_bRowUpdated = sal_False; 704cdf0e10cSrcweir m_bRowInserted = sal_False; 705cdf0e10cSrcweir m_bRowDeleted = sal_False; 706cdf0e10cSrcweir 707cdf0e10cSrcweir if(m_aInsertRow.isValid()) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1; 710cdf0e10cSrcweir for(;aIter != m_aInsertRow->get().end();++aIter) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir (*aIter)->setBound(sal_False); 713cdf0e10cSrcweir (*aIter)->setNull(); 714cdf0e10cSrcweir } 715cdf0e10cSrcweir } 716cdf0e10cSrcweir } 717cdf0e10cSrcweir // ------------------------------------------------------------------------- 718cdf0e10cSrcweir 719cdf0e10cSrcweir void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException) 720cdf0e10cSrcweir { 721cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" ); 722cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 723cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 724cdf0e10cSrcweir 725cdf0e10cSrcweir if(!m_pTable || m_pTable->isReadOnly()) 726cdf0e10cSrcweir lcl_throwError(STR_TABLE_READONLY,*this); 727cdf0e10cSrcweir 728cdf0e10cSrcweir m_bInserted = sal_True; 729cdf0e10cSrcweir 730cdf0e10cSrcweir OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1; 731cdf0e10cSrcweir for(;aIter != m_aInsertRow->get().end();++aIter) 732cdf0e10cSrcweir { 733cdf0e10cSrcweir (*aIter)->setBound(sal_False); 734cdf0e10cSrcweir (*aIter)->setNull(); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir } 737cdf0e10cSrcweir // ------------------------------------------------------------------------- 738cdf0e10cSrcweir 739cdf0e10cSrcweir void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" ); 742cdf0e10cSrcweir } 743cdf0e10cSrcweir // ------------------------------------------------------------------------- 744cdf0e10cSrcweir void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateValue" ); 747cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 748cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 749cdf0e10cSrcweir 750cdf0e10cSrcweir checkIndex(columnIndex ); 751cdf0e10cSrcweir columnIndex = mapColumn(columnIndex); 752cdf0e10cSrcweir 753cdf0e10cSrcweir (m_aInsertRow->get())[columnIndex]->setBound(sal_True); 754cdf0e10cSrcweir *(m_aInsertRow->get())[columnIndex] = x; 755cdf0e10cSrcweir } 756cdf0e10cSrcweir // ----------------------------------------------------------------------------- 757cdf0e10cSrcweir 758cdf0e10cSrcweir void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNull" ); 761cdf0e10cSrcweir ORowSetValue aEmpty; 762cdf0e10cSrcweir updateValue(columnIndex,aEmpty); 763cdf0e10cSrcweir } 764cdf0e10cSrcweir // ------------------------------------------------------------------------- 765cdf0e10cSrcweir 766cdf0e10cSrcweir void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) 767cdf0e10cSrcweir { 768cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" ); 769cdf0e10cSrcweir updateValue(columnIndex,x); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir // ------------------------------------------------------------------------- 772cdf0e10cSrcweir void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) 773cdf0e10cSrcweir { 774cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateByte" ); 775cdf0e10cSrcweir updateValue(columnIndex,x); 776cdf0e10cSrcweir } 777cdf0e10cSrcweir // ------------------------------------------------------------------------- 778cdf0e10cSrcweir 779cdf0e10cSrcweir void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateShort" ); 782cdf0e10cSrcweir updateValue(columnIndex,x); 783cdf0e10cSrcweir } 784cdf0e10cSrcweir // ------------------------------------------------------------------------- 785cdf0e10cSrcweir void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateInt" ); 788cdf0e10cSrcweir updateValue(columnIndex,x); 789cdf0e10cSrcweir } 790cdf0e10cSrcweir // ------------------------------------------------------------------------- 791cdf0e10cSrcweir void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateLong" ); 794cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this ); 795cdf0e10cSrcweir } 796cdf0e10cSrcweir // ----------------------------------------------------------------------- 797cdf0e10cSrcweir void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" ); 800cdf0e10cSrcweir updateValue(columnIndex,x); 801cdf0e10cSrcweir } 802cdf0e10cSrcweir // ------------------------------------------------------------------------- 803cdf0e10cSrcweir 804cdf0e10cSrcweir void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" ); 807cdf0e10cSrcweir updateValue(columnIndex,x); 808cdf0e10cSrcweir } 809cdf0e10cSrcweir // ------------------------------------------------------------------------- 810cdf0e10cSrcweir void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) 811cdf0e10cSrcweir { 812cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateString" ); 813cdf0e10cSrcweir updateValue(columnIndex,x); 814cdf0e10cSrcweir } 815cdf0e10cSrcweir // ------------------------------------------------------------------------- 816cdf0e10cSrcweir void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) 817cdf0e10cSrcweir { 818cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" ); 819cdf0e10cSrcweir updateValue(columnIndex,x); 820cdf0e10cSrcweir } 821cdf0e10cSrcweir // ------------------------------------------------------------------------- 822cdf0e10cSrcweir void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDate" ); 825cdf0e10cSrcweir updateValue(columnIndex,x); 826cdf0e10cSrcweir } 827cdf0e10cSrcweir // ------------------------------------------------------------------------- 828cdf0e10cSrcweir 829cdf0e10cSrcweir void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTime" ); 832cdf0e10cSrcweir updateValue(columnIndex,x); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir // ------------------------------------------------------------------------- 835cdf0e10cSrcweir 836cdf0e10cSrcweir void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" ); 839cdf0e10cSrcweir updateValue(columnIndex,x); 840cdf0e10cSrcweir } 841cdf0e10cSrcweir // ------------------------------------------------------------------------- 842cdf0e10cSrcweir 843cdf0e10cSrcweir void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" ); 846cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 847cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 848cdf0e10cSrcweir 849cdf0e10cSrcweir if(!x.is()) 850cdf0e10cSrcweir ::dbtools::throwFunctionSequenceException(*this); 851cdf0e10cSrcweir 852cdf0e10cSrcweir Sequence<sal_Int8> aSeq; 853cdf0e10cSrcweir x->readBytes(aSeq,length); 854cdf0e10cSrcweir updateValue(columnIndex,aSeq); 855cdf0e10cSrcweir } 856cdf0e10cSrcweir // ------------------------------------------------------------------------- 857cdf0e10cSrcweir void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) 858cdf0e10cSrcweir { 859cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" ); 860cdf0e10cSrcweir updateBinaryStream(columnIndex,x,length); 861cdf0e10cSrcweir } 862cdf0e10cSrcweir // ------------------------------------------------------------------------- 863cdf0e10cSrcweir void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" ); 866cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 867cdf0e10cSrcweir checkDisposed(OResultSet_BASE::rBHelper.bDisposed); 868cdf0e10cSrcweir } 869cdf0e10cSrcweir // ------------------------------------------------------------------------- 870cdf0e10cSrcweir void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) 871cdf0e10cSrcweir { 872cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateObject" ); 873cdf0e10cSrcweir if (!::dbtools::implUpdateObject(this, columnIndex, x)) 874cdf0e10cSrcweir throw SQLException(); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir // ------------------------------------------------------------------------- 877cdf0e10cSrcweir 878cdf0e10cSrcweir void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) 879cdf0e10cSrcweir { 880cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" ); 881cdf0e10cSrcweir if (!::dbtools::implUpdateObject(this, columnIndex, x)) 882cdf0e10cSrcweir throw SQLException(); 883cdf0e10cSrcweir } 884cdf0e10cSrcweir // ------------------------------------------------------------------------- 885cdf0e10cSrcweir IPropertyArrayHelper* OResultSet::createArrayHelper( ) const 886cdf0e10cSrcweir { 887cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" ); 888cdf0e10cSrcweir Sequence< Property > aProps; 889cdf0e10cSrcweir describeProperties(aProps); 890cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps); 891cdf0e10cSrcweir } 892cdf0e10cSrcweir // ------------------------------------------------------------------------- 893cdf0e10cSrcweir IPropertyArrayHelper & OResultSet::getInfoHelper() 894cdf0e10cSrcweir { 895cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" ); 896cdf0e10cSrcweir return *const_cast<OResultSet*>(this)->getArrayHelper(); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir 899cdf0e10cSrcweir //------------------------------------------------------------------ 900cdf0e10cSrcweir sal_Bool OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition, 901cdf0e10cSrcweir sal_Int32 nFirstOffset, 902cdf0e10cSrcweir sal_Bool bEvaluate, 903cdf0e10cSrcweir sal_Bool bRetrieveData) 904cdf0e10cSrcweir { 905cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::ExecuteRow" ); 906cdf0e10cSrcweir OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::ExecuteRow: Analyzer isn't set!"); 907cdf0e10cSrcweir 908cdf0e10cSrcweir // Fuer weitere Fetch-Operationen werden diese Angaben ggf. veraendert ... 909cdf0e10cSrcweir IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition; 910cdf0e10cSrcweir sal_Int32 nOffset = nFirstOffset; 911cdf0e10cSrcweir 912cdf0e10cSrcweir const OSQLColumns & rTableCols = m_pTable->getTableColumns().getBody(); 913cdf0e10cSrcweir sal_Bool bHasRestriction = m_pSQLAnalyzer->hasRestriction(); 914cdf0e10cSrcweir again: 915cdf0e10cSrcweir 916cdf0e10cSrcweir // protect from reading over the end when someboby is inserting while we are reading 917cdf0e10cSrcweir // this method works only for dBase at the moment !!!! 918cdf0e10cSrcweir if (eCursorPosition == IResultSetHelper::NEXT && m_nFilePos == m_nLastVisitedPos) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir return sal_False; 921cdf0e10cSrcweir } 922cdf0e10cSrcweir 923cdf0e10cSrcweir if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos)) 924cdf0e10cSrcweir { 925cdf0e10cSrcweir return sal_False; 926cdf0e10cSrcweir } 927cdf0e10cSrcweir 928cdf0e10cSrcweir if (!bEvaluate) // Laeuft keine Auswertung, dann nur Ergebniszeile fuellen 929cdf0e10cSrcweir { 930cdf0e10cSrcweir m_pTable->fetchRow(m_aRow,rTableCols, sal_True,bRetrieveData); 931cdf0e10cSrcweir } 932cdf0e10cSrcweir else 933cdf0e10cSrcweir { 934cdf0e10cSrcweir m_pTable->fetchRow(m_aEvaluateRow, rTableCols, sal_True,bRetrieveData || bHasRestriction); 935cdf0e10cSrcweir 936cdf0e10cSrcweir if ( ( !m_bShowDeleted 937cdf0e10cSrcweir && m_aEvaluateRow->isDeleted() 938cdf0e10cSrcweir ) 939cdf0e10cSrcweir || ( bHasRestriction 940cdf0e10cSrcweir && !m_pSQLAnalyzer->evaluateRestriction() 941cdf0e10cSrcweir ) 942cdf0e10cSrcweir ) 943cdf0e10cSrcweir { // naechsten Satz auswerten 944cdf0e10cSrcweir // aktuelle Zeile loeschen im Keyset 945cdf0e10cSrcweir if (m_pEvaluationKeySet) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir ++m_aEvaluateIter; 948cdf0e10cSrcweir if (m_pEvaluationKeySet->end() != m_aEvaluateIter) 949cdf0e10cSrcweir nOffset = (*m_aEvaluateIter); 950cdf0e10cSrcweir else 951cdf0e10cSrcweir { 952cdf0e10cSrcweir return sal_False; 953cdf0e10cSrcweir } 954cdf0e10cSrcweir } 955cdf0e10cSrcweir else if (m_pFileSet.isValid()) 956cdf0e10cSrcweir { 957cdf0e10cSrcweir OSL_ENSURE(//!m_pFileSet->IsFrozen() && 958cdf0e10cSrcweir eCursorPosition == IResultSetHelper::NEXT, "Falsche CursorPosition!"); 959cdf0e10cSrcweir eCursorPosition = IResultSetHelper::NEXT; 960cdf0e10cSrcweir nOffset = 1; 961cdf0e10cSrcweir } 962cdf0e10cSrcweir else if (eCursorPosition == IResultSetHelper::FIRST || 963cdf0e10cSrcweir eCursorPosition == IResultSetHelper::NEXT || 964cdf0e10cSrcweir eCursorPosition == IResultSetHelper::ABSOLUTE) 965cdf0e10cSrcweir { 966cdf0e10cSrcweir eCursorPosition = IResultSetHelper::NEXT; 967cdf0e10cSrcweir nOffset = 1; 968cdf0e10cSrcweir } 969cdf0e10cSrcweir else if (eCursorPosition == IResultSetHelper::LAST || 970cdf0e10cSrcweir eCursorPosition == IResultSetHelper::PRIOR) 971cdf0e10cSrcweir { 972cdf0e10cSrcweir eCursorPosition = IResultSetHelper::PRIOR; 973cdf0e10cSrcweir nOffset = 1; 974cdf0e10cSrcweir } 975cdf0e10cSrcweir else if (eCursorPosition == IResultSetHelper::RELATIVE) 976cdf0e10cSrcweir { 977cdf0e10cSrcweir eCursorPosition = (nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR; 978cdf0e10cSrcweir } 979cdf0e10cSrcweir else 980cdf0e10cSrcweir { 981cdf0e10cSrcweir // aStatus.Set(SQL_STAT_NO_DATA_FOUND); 982cdf0e10cSrcweir return sal_False; 983cdf0e10cSrcweir } 984cdf0e10cSrcweir // Nochmal probieren ... 985cdf0e10cSrcweir goto again; 986cdf0e10cSrcweir } 987cdf0e10cSrcweir } 988cdf0e10cSrcweir 989cdf0e10cSrcweir // Evaluate darf nur gesetzt sein, 990cdf0e10cSrcweir // wenn der Keyset weiter aufgebaut werden soll 991cdf0e10cSrcweir if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT ) 992cdf0e10cSrcweir && !isCount() 993cdf0e10cSrcweir && bEvaluate 994cdf0e10cSrcweir ) 995cdf0e10cSrcweir { 996cdf0e10cSrcweir if (m_pSortIndex) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir OKeyValue* pKeyValue = GetOrderbyKeyValue( m_aSelectRow ); 999cdf0e10cSrcweir m_pSortIndex->AddKeyValue(pKeyValue); 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir else if (m_pFileSet.isValid()) 1002cdf0e10cSrcweir { 1003cdf0e10cSrcweir // OSL_ENSURE(!m_pFileSet->IsFrozen() , "Falsche CursorPosition!"); 1004cdf0e10cSrcweir sal_uInt32 nBookmarkValue = Abs((sal_Int32)(m_aEvaluateRow->get())[0]->getValue()); 1005cdf0e10cSrcweir m_pFileSet->get().push_back(nBookmarkValue); 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir } 1008cdf0e10cSrcweir else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir sal_Bool bOK = sal_True; 1011cdf0e10cSrcweir if (bEvaluate) 1012cdf0e10cSrcweir { 1013cdf0e10cSrcweir // jetzt die eigentliche Ergebniszeile Lesen 1014cdf0e10cSrcweir bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,sal_True); 1015cdf0e10cSrcweir } 1016cdf0e10cSrcweir 1017cdf0e10cSrcweir if (bOK) 1018cdf0e10cSrcweir { 1019cdf0e10cSrcweir // Nur die zu aendernden Werte uebergeben: 1020cdf0e10cSrcweir if(!m_pTable->UpdateRow(m_aAssignValues.getBody(),m_aEvaluateRow,m_xColsIdx)) 1021cdf0e10cSrcweir return sal_False; 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_DELETE) 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir sal_Bool bOK = sal_True; 1027cdf0e10cSrcweir if (bEvaluate) 1028cdf0e10cSrcweir { 1029cdf0e10cSrcweir bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,sal_True); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir if (bOK) 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir if(!m_pTable->DeleteRow(m_xColumns.getBody())) 1034cdf0e10cSrcweir return sal_False; 1035cdf0e10cSrcweir } 1036cdf0e10cSrcweir } 1037cdf0e10cSrcweir return sal_True; 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir //------------------------------------------------------------------- 1041cdf0e10cSrcweir sal_Bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Bool bRetrieveData) 1042cdf0e10cSrcweir { 1043cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::Move" ); 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir //IgnoreDeletedRows: 1046cdf0e10cSrcweir // 1047cdf0e10cSrcweir sal_Int32 nTempPos = m_nRowPos; 1048cdf0e10cSrcweir // exclusiver zugriff auf die Tabelle 1049cdf0e10cSrcweir // vos::OGuard* pGuard = m_pTable->Lock(); 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && 1052cdf0e10cSrcweir !isCount()) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir if (!m_pFileSet.isValid()) // kein Index verfuegbar 1055cdf0e10cSrcweir { 1056cdf0e10cSrcweir // Normales FETCH 1057cdf0e10cSrcweir ExecuteRow(eCursorPosition,nOffset,sal_False,bRetrieveData); 1058cdf0e10cSrcweir 1059cdf0e10cSrcweir // now set the bookmark for outside this is the logical pos and not the file pos 1060cdf0e10cSrcweir *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1); 1061cdf0e10cSrcweir } 1062cdf0e10cSrcweir else 1063cdf0e10cSrcweir { 1064cdf0e10cSrcweir switch(eCursorPosition) 1065cdf0e10cSrcweir { 1066cdf0e10cSrcweir case IResultSetHelper::NEXT: 1067cdf0e10cSrcweir ++m_nRowPos; 1068cdf0e10cSrcweir break; 1069cdf0e10cSrcweir case IResultSetHelper::PRIOR: 1070cdf0e10cSrcweir if (m_nRowPos >= 0) 1071cdf0e10cSrcweir --m_nRowPos; 1072cdf0e10cSrcweir break; 1073cdf0e10cSrcweir case IResultSetHelper::FIRST: 1074cdf0e10cSrcweir m_nRowPos = 0; 1075cdf0e10cSrcweir break; 1076cdf0e10cSrcweir case IResultSetHelper::LAST: 1077cdf0e10cSrcweir // OSL_ENSURE(IsRowCountFinal(), "Fehler im Keyset!"); // muss eingefroren sein, sonst Fehler beim SQLCursor 1078cdf0e10cSrcweir m_nRowPos = m_pFileSet->get().size() - 1; 1079cdf0e10cSrcweir break; 1080cdf0e10cSrcweir case IResultSetHelper::RELATIVE: 1081cdf0e10cSrcweir m_nRowPos += nOffset; 1082cdf0e10cSrcweir break; 1083cdf0e10cSrcweir case IResultSetHelper::ABSOLUTE: 1084cdf0e10cSrcweir case IResultSetHelper::BOOKMARK: 1085cdf0e10cSrcweir if ( m_nRowPos == (nOffset -1) ) 1086cdf0e10cSrcweir return sal_True; 1087cdf0e10cSrcweir m_nRowPos = nOffset -1; 1088cdf0e10cSrcweir break; 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir // OffRange? 1092cdf0e10cSrcweir // Der FileCursor ist ausserhalb des gueltigen Bereichs, wenn 1093cdf0e10cSrcweir // a.) m_nRowPos < 1 1094cdf0e10cSrcweir // b.) Ein KeySet besteht und m_nRowPos > m_pFileSet->size() 1095cdf0e10cSrcweir if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size() )) // && m_pFileSet->IsFrozen() 1096cdf0e10cSrcweir { 1097cdf0e10cSrcweir // aStatus.Set(SQL_STAT_NO_DATA_FOUND); 1098cdf0e10cSrcweir goto Error; 1099cdf0e10cSrcweir } 1100cdf0e10cSrcweir else 1101cdf0e10cSrcweir { 1102cdf0e10cSrcweir if (m_nRowPos < (sal_Int32)m_pFileSet->get().size()) 1103cdf0e10cSrcweir { 1104cdf0e10cSrcweir // Fetch ueber Index 1105cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,(m_pFileSet->get())[m_nRowPos],sal_False,bRetrieveData); 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir // now set the bookmark for outside 1108cdf0e10cSrcweir *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1); 1109cdf0e10cSrcweir if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() ) 1110cdf0e10cSrcweir { 1111cdf0e10cSrcweir m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping); 1112cdf0e10cSrcweir } 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir else // Index muss weiter aufgebaut werden 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir // Zunaechst auf die letzte bekannte Zeile setzen 1117cdf0e10cSrcweir if (!m_pFileSet->get().empty()) 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir m_aFileSetIter = m_pFileSet->get().end()-1; 1120cdf0e10cSrcweir // m_pFileSet->SeekPos(m_pFileSet->size()-1); 1121cdf0e10cSrcweir m_pTable->seekRow(IResultSetHelper::BOOKMARK, *m_aFileSetIter, m_nFilePos); 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir sal_Bool bOK = sal_True; 1124cdf0e10cSrcweir // Ermitteln der Anzahl weiterer Fetches 1125cdf0e10cSrcweir while (bOK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size()) 1126cdf0e10cSrcweir { 1127cdf0e10cSrcweir if (m_pEvaluationKeySet) 1128cdf0e10cSrcweir { 1129cdf0e10cSrcweir if (m_nRowPos >= (sal_Int32)m_pEvaluationKeySet->size()) 1130cdf0e10cSrcweir return sal_False; 1131cdf0e10cSrcweir // aStatus.Set(SQL_STAT_NO_DATA_FOUND); 1132cdf0e10cSrcweir else if (m_nRowPos == 0) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir m_aEvaluateIter = m_pEvaluationKeySet->begin(); 1135cdf0e10cSrcweir bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,sal_True, bRetrieveData); 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir else 1138cdf0e10cSrcweir { 1139cdf0e10cSrcweir ++m_aEvaluateIter; 1140cdf0e10cSrcweir bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,sal_True, bRetrieveData); 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir } 1143cdf0e10cSrcweir else 1144cdf0e10cSrcweir bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True, sal_False);//bRetrieveData); 1145cdf0e10cSrcweir } 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir if (bOK) 1148cdf0e10cSrcweir { 1149cdf0e10cSrcweir // jetzt nochmal die Ergebnisse lesen 1150cdf0e10cSrcweir m_pTable->fetchRow(m_aRow, m_pTable->getTableColumns().getBody(), sal_True,bRetrieveData); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir // now set the bookmark for outside 1153cdf0e10cSrcweir *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() ) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping); 1158cdf0e10cSrcweir } 1159cdf0e10cSrcweir } 1160cdf0e10cSrcweir else if (!m_pFileSet->isFrozen()) // keinen gueltigen Satz gefunden 1161cdf0e10cSrcweir { 1162cdf0e10cSrcweir //m_pFileSet->Freeze(); 1163cdf0e10cSrcweir m_pFileSet->setFrozen(); 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir // DELETEZ(m_pEvaluationKeySet); 1166cdf0e10cSrcweir m_pEvaluationKeySet = NULL; 1167cdf0e10cSrcweir // aStatus.Set(SQL_STAT_NO_DATA_FOUND); 1168cdf0e10cSrcweir goto Error; 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir } 1172cdf0e10cSrcweir } 1173cdf0e10cSrcweir } 1174cdf0e10cSrcweir else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && isCount()) 1175cdf0e10cSrcweir { 1176cdf0e10cSrcweir // Fetch des COUNT(*) 1177cdf0e10cSrcweir switch (eCursorPosition) 1178cdf0e10cSrcweir { 1179cdf0e10cSrcweir case IResultSetHelper::NEXT: 1180cdf0e10cSrcweir ++m_nRowPos; 1181cdf0e10cSrcweir break; 1182cdf0e10cSrcweir case IResultSetHelper::PRIOR: 1183cdf0e10cSrcweir --m_nRowPos; 1184cdf0e10cSrcweir break; 1185cdf0e10cSrcweir case IResultSetHelper::FIRST: 1186cdf0e10cSrcweir m_nRowPos = 0; 1187cdf0e10cSrcweir break; 1188cdf0e10cSrcweir case IResultSetHelper::LAST: 1189cdf0e10cSrcweir m_nRowPos = 0; 1190cdf0e10cSrcweir break; 1191cdf0e10cSrcweir case IResultSetHelper::RELATIVE: 1192cdf0e10cSrcweir m_nRowPos += nOffset; 1193cdf0e10cSrcweir break; 1194cdf0e10cSrcweir case IResultSetHelper::ABSOLUTE: 1195cdf0e10cSrcweir case IResultSetHelper::BOOKMARK: 1196cdf0e10cSrcweir m_nRowPos = nOffset - 1; 1197cdf0e10cSrcweir break; 1198cdf0e10cSrcweir } 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir if ( m_nRowPos < 0 ) 1201cdf0e10cSrcweir goto Error; 1202cdf0e10cSrcweir else if (m_nRowPos == 0) 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir // COUNT(*) in Ergebnisrow packen 1205cdf0e10cSrcweir // (muss die erste und einzige Variable in der Row sein) 1206cdf0e10cSrcweir if (m_aRow->get().size() >= 2) 1207cdf0e10cSrcweir { 1208cdf0e10cSrcweir *(m_aRow->get())[1] = m_nRowCountResult; 1209cdf0e10cSrcweir *(m_aRow->get())[0] = sal_Int32(1); 1210cdf0e10cSrcweir (m_aRow->get())[1]->setBound(sal_True); 1211cdf0e10cSrcweir (m_aSelectRow->get())[1] = (m_aRow->get())[1]; 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir else 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir m_bEOF = sal_True; 1217cdf0e10cSrcweir m_nRowPos = 1; 1218cdf0e10cSrcweir return sal_False; 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir } 1221cdf0e10cSrcweir else 1222cdf0e10cSrcweir // Fetch nur bei SELECT moeglich! 1223cdf0e10cSrcweir return sal_False; 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir return sal_True; 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir Error: 1228cdf0e10cSrcweir // steht der Cursor vor dem ersten Satz 1229cdf0e10cSrcweir // dann wird die position beibehalten 1230cdf0e10cSrcweir if (nTempPos == -1) 1231cdf0e10cSrcweir m_nRowPos = nTempPos; 1232cdf0e10cSrcweir else 1233cdf0e10cSrcweir { 1234cdf0e10cSrcweir switch(eCursorPosition) 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir case IResultSetHelper::PRIOR: 1237cdf0e10cSrcweir case IResultSetHelper::FIRST: 1238cdf0e10cSrcweir m_nRowPos = -1; 1239cdf0e10cSrcweir break; 1240cdf0e10cSrcweir case IResultSetHelper::LAST: 1241cdf0e10cSrcweir case IResultSetHelper::NEXT: 1242cdf0e10cSrcweir case IResultSetHelper::ABSOLUTE: 1243cdf0e10cSrcweir case IResultSetHelper::RELATIVE: 1244cdf0e10cSrcweir if (nOffset > 0) 1245cdf0e10cSrcweir m_nRowPos = m_pFileSet.isValid() ? (sal_Int32)m_pFileSet->get().size() : -1; 1246cdf0e10cSrcweir else if (nOffset < 0) 1247cdf0e10cSrcweir m_nRowPos = -1; 1248cdf0e10cSrcweir break; 1249cdf0e10cSrcweir case IResultSetHelper::BOOKMARK: 1250cdf0e10cSrcweir m_nRowPos = nTempPos; // vorherige Position 1251cdf0e10cSrcweir } 1252cdf0e10cSrcweir } 1253cdf0e10cSrcweir // delete pGuard; 1254cdf0e10cSrcweir // rMode = (!bShowDeleted && aStatus.IsSuccessful() && m_aRow->isDeleted()) ? // keine Anzeige von geloeschten Saetzen 1255cdf0e10cSrcweir // OCursor::SQL_MOD_INVALID : OCursor::SQL_MOD_NONE; 1256cdf0e10cSrcweir return sal_False; 1257cdf0e10cSrcweir } 1258cdf0e10cSrcweir // ------------------------------------------------------------------------- 1259cdf0e10cSrcweir void OResultSet::sortRows() 1260cdf0e10cSrcweir { 1261cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::sortRows" ); 1262cdf0e10cSrcweir if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber.size() == 1) 1263cdf0e10cSrcweir { 1264cdf0e10cSrcweir // Ist nur ein Feld fuer die Sortierung angegeben 1265cdf0e10cSrcweir // Und diese Feld ist indiziert, dann den Index ausnutzen 1266cdf0e10cSrcweir Reference<XIndexesSupplier> xIndexSup; 1267cdf0e10cSrcweir m_pTable->queryInterface(::getCppuType((const Reference<XIndexesSupplier>*)0)) >>= xIndexSup; 1268cdf0e10cSrcweir // Reference<XIndexesSupplier> xIndexSup(m_pTable,UNO_QUERY); 1269cdf0e10cSrcweir Reference<XIndexAccess> xIndexes; 1270cdf0e10cSrcweir if(xIndexSup.is()) 1271cdf0e10cSrcweir { 1272cdf0e10cSrcweir xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY); 1273cdf0e10cSrcweir Reference<XPropertySet> xColProp; 1274cdf0e10cSrcweir if(m_aOrderbyColumnNumber[0] < xIndexes->getCount()) 1275cdf0e10cSrcweir { 1276cdf0e10cSrcweir xColProp.set(xIndexes->getByIndex(m_aOrderbyColumnNumber[0]),UNO_QUERY); 1277cdf0e10cSrcweir // iterate through the indexes to find the matching column 1278cdf0e10cSrcweir const sal_Int32 nCount = xIndexes->getCount(); 1279cdf0e10cSrcweir for(sal_Int32 i=0; i < nCount;++i) 1280cdf0e10cSrcweir { 1281cdf0e10cSrcweir Reference<XColumnsSupplier> xIndex(xIndexes->getByIndex(i),UNO_QUERY); 1282cdf0e10cSrcweir Reference<XNameAccess> xIndexCols = xIndex->getColumns(); 1283cdf0e10cSrcweir if(xIndexCols->hasByName(comphelper::getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))) 1284cdf0e10cSrcweir { 1285cdf0e10cSrcweir m_pFileSet = new OKeySet(); 1286cdf0e10cSrcweir 1287cdf0e10cSrcweir if(fillIndexValues(xIndex)) 1288cdf0e10cSrcweir return; 1289cdf0e10cSrcweir } 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir } 1292cdf0e10cSrcweir } 1293cdf0e10cSrcweir } 1294cdf0e10cSrcweir 1295cdf0e10cSrcweir OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size()); 1296cdf0e10cSrcweir ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin(); 1297cdf0e10cSrcweir for (::std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i) 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir OSL_ENSURE((sal_Int32)m_aSelectRow->get().size() > *aOrderByIter,"Invalid Index"); 1300cdf0e10cSrcweir switch ((*(m_aSelectRow->get().begin()+*aOrderByIter))->getValue().getTypeKind()) 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir case DataType::CHAR: 1303cdf0e10cSrcweir case DataType::VARCHAR: 1304cdf0e10cSrcweir case DataType::LONGVARCHAR: 1305cdf0e10cSrcweir eKeyType[i] = SQL_ORDERBYKEY_STRING; 1306cdf0e10cSrcweir break; 1307cdf0e10cSrcweir 1308cdf0e10cSrcweir case DataType::OTHER: 1309cdf0e10cSrcweir case DataType::TINYINT: 1310cdf0e10cSrcweir case DataType::SMALLINT: 1311cdf0e10cSrcweir case DataType::INTEGER: 1312cdf0e10cSrcweir case DataType::DECIMAL: 1313cdf0e10cSrcweir case DataType::NUMERIC: 1314cdf0e10cSrcweir case DataType::REAL: 1315cdf0e10cSrcweir case DataType::DOUBLE: 1316cdf0e10cSrcweir case DataType::DATE: 1317cdf0e10cSrcweir case DataType::TIME: 1318cdf0e10cSrcweir case DataType::TIMESTAMP: 1319cdf0e10cSrcweir case DataType::BIT: 1320cdf0e10cSrcweir eKeyType[i] = SQL_ORDERBYKEY_DOUBLE; 1321cdf0e10cSrcweir break; 1322cdf0e10cSrcweir 1323cdf0e10cSrcweir // Andere Typen sind nicht implementiert (und damit immer sal_False) 1324cdf0e10cSrcweir default: 1325cdf0e10cSrcweir eKeyType[i] = SQL_ORDERBYKEY_NONE; 1326cdf0e10cSrcweir OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert"); 1327cdf0e10cSrcweir break; 1328cdf0e10cSrcweir } 1329cdf0e10cSrcweir (m_aSelectRow->get())[*aOrderByIter]->setBound(sal_True); 1330cdf0e10cSrcweir } 1331cdf0e10cSrcweir 1332cdf0e10cSrcweir m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending); 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir if (m_pEvaluationKeySet) 1335cdf0e10cSrcweir { 1336cdf0e10cSrcweir m_aEvaluateIter = m_pEvaluationKeySet->begin(); 1337cdf0e10cSrcweir 1338cdf0e10cSrcweir while (m_aEvaluateIter != m_pEvaluationKeySet->end()) 1339cdf0e10cSrcweir { 1340cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True); 1341cdf0e10cSrcweir ++m_aEvaluateIter; 1342cdf0e10cSrcweir } 1343cdf0e10cSrcweir } 1344cdf0e10cSrcweir else 1345cdf0e10cSrcweir { 1346cdf0e10cSrcweir while ( ExecuteRow( IResultSetHelper::NEXT, 1, sal_False, sal_True ) ) 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir m_aSelectRow->get()[0]->setValue( m_aRow->get()[0]->getValue() ); 1349cdf0e10cSrcweir if ( m_pSQLAnalyzer->hasFunctions() ) 1350cdf0e10cSrcweir m_pSQLAnalyzer->setSelectionEvaluationResult( m_aSelectRow, m_aColMapping ); 1351cdf0e10cSrcweir const sal_Int32 nBookmark = (*m_aRow->get().begin())->getValue(); 1352cdf0e10cSrcweir ExecuteRow( IResultSetHelper::BOOKMARK, nBookmark, sal_True, sal_False ); 1353cdf0e10cSrcweir } 1354cdf0e10cSrcweir } 1355cdf0e10cSrcweir 1356cdf0e10cSrcweir // Sortiertes Keyset erzeugen 1357cdf0e10cSrcweir // DELETEZ(m_pEvaluationKeySet); 1358cdf0e10cSrcweir m_pEvaluationKeySet = NULL; 1359cdf0e10cSrcweir m_pFileSet = NULL; 1360cdf0e10cSrcweir m_pFileSet = m_pSortIndex->CreateKeySet(); 1361cdf0e10cSrcweir // if(!bDistinct) 1362cdf0e10cSrcweir // SetRowCount(pFileSet->count()); 1363cdf0e10cSrcweir DELETEZ(m_pSortIndex); 1364cdf0e10cSrcweir // Nun kann ueber den Index sortiert zugegriffen werden. 1365cdf0e10cSrcweir } 1366cdf0e10cSrcweir 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir // ------------------------------------------------------------------------- 1369cdf0e10cSrcweir sal_Bool OResultSet::OpenImpl() 1370cdf0e10cSrcweir { 1371cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OpenImpl" ); 1372cdf0e10cSrcweir OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!"); 1373cdf0e10cSrcweir if(!m_pTable) 1374cdf0e10cSrcweir { 1375cdf0e10cSrcweir const OSQLTables& xTabs = m_aSQLIterator.getTables(); 1376cdf0e10cSrcweir if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) 1377cdf0e10cSrcweir lcl_throwError(STR_QUERY_TOO_COMPLEX,*this); 1378cdf0e10cSrcweir 1379cdf0e10cSrcweir if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() ) 1380cdf0e10cSrcweir lcl_throwError(STR_QUERY_MORE_TABLES,*this); 1381cdf0e10cSrcweir 1382cdf0e10cSrcweir OSQLTable xTable = xTabs.begin()->second; 1383cdf0e10cSrcweir m_xColumns = m_aSQLIterator.getSelectColumns(); 1384cdf0e10cSrcweir 1385cdf0e10cSrcweir m_xColNames = xTable->getColumns(); 1386cdf0e10cSrcweir m_xColsIdx.set(m_xColNames,UNO_QUERY); 1387cdf0e10cSrcweir doTableSpecials(xTable); 1388cdf0e10cSrcweir Reference<XComponent> xComp(xTable,UNO_QUERY); 1389cdf0e10cSrcweir if(xComp.is()) 1390cdf0e10cSrcweir xComp->addEventListener(this); 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir 1393cdf0e10cSrcweir m_pTable->refreshHeader(); 1394cdf0e10cSrcweir 1395cdf0e10cSrcweir sal_Int32 nColumnCount = m_xColsIdx->getCount(); 1396cdf0e10cSrcweir 1397cdf0e10cSrcweir initializeRow(m_aRow,nColumnCount); 1398cdf0e10cSrcweir initializeRow(m_aEvaluateRow,nColumnCount); 1399cdf0e10cSrcweir initializeRow(m_aInsertRow,nColumnCount); 1400cdf0e10cSrcweir 1401cdf0e10cSrcweir 1402cdf0e10cSrcweir m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE; 1403cdf0e10cSrcweir 1404cdf0e10cSrcweir // Neuen Index aufbauen: 1405cdf0e10cSrcweir m_pFileSet = NULL; 1406cdf0e10cSrcweir // DELETEZ(m_pEvaluationKeySet); 1407cdf0e10cSrcweir 1408cdf0e10cSrcweir // An den Anfang positionieren 1409cdf0e10cSrcweir m_nRowPos = -1; 1410cdf0e10cSrcweir m_nFilePos = 0; 1411cdf0e10cSrcweir m_nRowCountResult = -1; 1412cdf0e10cSrcweir 1413cdf0e10cSrcweir // exclusiver zugriff auf die Tabelle 1414cdf0e10cSrcweir // vos::OGuard* pGuard = pTable->Lock(); 1415cdf0e10cSrcweir m_nLastVisitedPos = m_pTable->getCurrentLastPos(); 1416cdf0e10cSrcweir 1417cdf0e10cSrcweir switch(m_aSQLIterator.getStatementType()) 1418cdf0e10cSrcweir { 1419cdf0e10cSrcweir case SQL_STATEMENT_SELECT: 1420cdf0e10cSrcweir { 1421cdf0e10cSrcweir if(isCount()) 1422cdf0e10cSrcweir { 1423cdf0e10cSrcweir if(m_xColumns->get().size() > 1) 1424cdf0e10cSrcweir lcl_throwError(STR_QUERY_COMPLEX_COUNT,*this); 1425cdf0e10cSrcweir 1426cdf0e10cSrcweir m_nRowCountResult = 0; 1427cdf0e10cSrcweir // Vorlaeufig einfach ueber alle Datensaetze iterieren und 1428cdf0e10cSrcweir // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen): 1429cdf0e10cSrcweir { 1430cdf0e10cSrcweir sal_Bool bOK = sal_True; 1431cdf0e10cSrcweir if (m_pEvaluationKeySet) 1432cdf0e10cSrcweir { 1433cdf0e10cSrcweir m_aEvaluateIter = m_pEvaluationKeySet->begin(); 1434cdf0e10cSrcweir bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir } 1437cdf0e10cSrcweir while (bOK) 1438cdf0e10cSrcweir { 1439cdf0e10cSrcweir if (m_pEvaluationKeySet) 1440cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True); 1441cdf0e10cSrcweir else 1442cdf0e10cSrcweir bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True); 1443cdf0e10cSrcweir 1444cdf0e10cSrcweir if (bOK) 1445cdf0e10cSrcweir { 1446cdf0e10cSrcweir m_nRowCountResult++; 1447cdf0e10cSrcweir if(m_pEvaluationKeySet) 1448cdf0e10cSrcweir { 1449cdf0e10cSrcweir ++m_aEvaluateIter; 1450cdf0e10cSrcweir bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); 1451cdf0e10cSrcweir } 1452cdf0e10cSrcweir } 1453cdf0e10cSrcweir } 1454cdf0e10cSrcweir 1455cdf0e10cSrcweir // Ergebnis von COUNT(*) in m_nRowCountResult merken. 1456cdf0e10cSrcweir // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser 1457cdf0e10cSrcweir // Anfrage = 1! 1458cdf0e10cSrcweir m_pEvaluationKeySet = NULL; 1459cdf0e10cSrcweir // DELETEZ(m_pEvaluationKeySet); 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir } 1462cdf0e10cSrcweir else 1463cdf0e10cSrcweir { 1464cdf0e10cSrcweir sal_Bool bDistinct = sal_False; 1465cdf0e10cSrcweir sal_Bool bWasSorted = sal_False; 1466cdf0e10cSrcweir OSQLParseNode *pDistinct = m_pParseTree->getChild(1); 1467cdf0e10cSrcweir ::std::vector<sal_Int32> aOrderbyColumnNumberSave; 1468cdf0e10cSrcweir ::std::vector<TAscendingOrder> aOrderbyAscendingSave; 1469cdf0e10cSrcweir 1470cdf0e10cSrcweir if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT ) 1471cdf0e10cSrcweir { 1472cdf0e10cSrcweir // Sort on all columns, saving original order for later 1473cdf0e10cSrcweir if(IsSorted()) 1474cdf0e10cSrcweir { 1475cdf0e10cSrcweir aOrderbyColumnNumberSave = m_aOrderbyColumnNumber;// .assign(m_aOrderbyColumnNumber.begin(), m_aOrderbyColumnNumber.end()); 1476cdf0e10cSrcweir m_aOrderbyColumnNumber.clear(); 1477cdf0e10cSrcweir aOrderbyAscendingSave.assign(m_aOrderbyAscending.begin(), m_aOrderbyAscending.end()); 1478cdf0e10cSrcweir bWasSorted = sal_True; 1479cdf0e10cSrcweir } 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir // the first column is the bookmark column 1482cdf0e10cSrcweir ::std::vector<sal_Int32>::iterator aColStart = (m_aColMapping.begin()+1); 1483cdf0e10cSrcweir ::std::copy(aColStart, m_aColMapping.end(),::std::back_inserter(m_aOrderbyColumnNumber)); 1484cdf0e10cSrcweir // m_aOrderbyColumnNumber.assign(aColStart, m_aColMapping.end()); 1485cdf0e10cSrcweir m_aOrderbyAscending.assign(m_aColMapping.size()-1, SQL_ASC); 1486cdf0e10cSrcweir bDistinct = sal_True; 1487cdf0e10cSrcweir } 1488cdf0e10cSrcweir 1489cdf0e10cSrcweir if (IsSorted()) 1490cdf0e10cSrcweir sortRows(); 1491cdf0e10cSrcweir 1492cdf0e10cSrcweir if (!m_pFileSet.isValid()) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir m_pFileSet = new OKeySet(); 1495cdf0e10cSrcweir 1496cdf0e10cSrcweir if (!m_pSQLAnalyzer->hasRestriction()) 1497cdf0e10cSrcweir // jetzt kann das Keyset schon gefuellt werden! 1498cdf0e10cSrcweir // Aber Achtung: es wird davon ausgegangen, das die FilePositionen als Folge 1..n 1499cdf0e10cSrcweir // abgelegt werden! 1500cdf0e10cSrcweir { 1501cdf0e10cSrcweir if ( m_nLastVisitedPos > 0) 1502cdf0e10cSrcweir m_pFileSet->get().reserve( m_nLastVisitedPos ); 1503cdf0e10cSrcweir for (sal_Int32 i = 0; i < m_nLastVisitedPos; i++) 1504cdf0e10cSrcweir m_pFileSet->get().push_back(i + 1); 1505cdf0e10cSrcweir } 1506cdf0e10cSrcweir } 1507cdf0e10cSrcweir OSL_ENSURE(m_pFileSet.isValid(),"Kein KeySet vorhanden! :-("); 1508cdf0e10cSrcweir 1509cdf0e10cSrcweir if(bDistinct && m_pFileSet.isValid()) // sicher ist sicher 1510cdf0e10cSrcweir { 1511cdf0e10cSrcweir OValueRow aSearchRow = new OValueVector(m_aRow->get().size()); 1512cdf0e10cSrcweir OValueRefVector::Vector::iterator aRowIter = m_aRow->get().begin(); 1513cdf0e10cSrcweir OValueVector::Vector::iterator aSearchIter = aSearchRow->get().begin(); 1514cdf0e10cSrcweir for ( ++aRowIter,++aSearchIter; // the first column is the bookmark column 1515cdf0e10cSrcweir aRowIter != m_aRow->get().end(); 1516cdf0e10cSrcweir ++aRowIter,++aSearchIter) 1517cdf0e10cSrcweir aSearchIter->setBound((*aRowIter)->isBound()); 1518cdf0e10cSrcweir 1519cdf0e10cSrcweir size_t nMaxRow = m_pFileSet->get().size(); 1520cdf0e10cSrcweir 1521cdf0e10cSrcweir if (nMaxRow) 1522cdf0e10cSrcweir { 1523cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1524cdf0e10cSrcweir sal_Int32 nFound=0; 1525cdf0e10cSrcweir #endif 1526cdf0e10cSrcweir sal_Int32 nPos; 1527cdf0e10cSrcweir sal_Int32 nKey; 1528cdf0e10cSrcweir 1529cdf0e10cSrcweir for( size_t j = nMaxRow-1; j > 0; --j) 1530cdf0e10cSrcweir { 1531cdf0e10cSrcweir nPos = (m_pFileSet->get())[j]; 1532cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,nPos,sal_False); 1533cdf0e10cSrcweir m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping); 1534cdf0e10cSrcweir { // copy row values 1535cdf0e10cSrcweir OValueRefVector::Vector::iterator copyFrom = m_aSelectRow->get().begin(); 1536cdf0e10cSrcweir OValueVector::Vector::iterator copyTo = aSearchRow->get().begin(); 1537cdf0e10cSrcweir for ( ++copyFrom,++copyTo; // the first column is the bookmark column 1538cdf0e10cSrcweir copyFrom != m_aSelectRow->get().end(); 1539cdf0e10cSrcweir ++copyFrom,++copyTo) 1540cdf0e10cSrcweir *copyTo = *(*copyFrom); 1541cdf0e10cSrcweir // *aSearchRow = *m_aRow; 1542cdf0e10cSrcweir } 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir // compare with next row 1545cdf0e10cSrcweir nKey = (m_pFileSet->get())[j-1]; 1546cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,nKey,sal_False); 1547cdf0e10cSrcweir m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping); 1548cdf0e10cSrcweir OValueRefVector::Vector::iterator loopInRow = m_aSelectRow->get().begin(); 1549cdf0e10cSrcweir OValueVector::Vector::iterator existentInSearchRow = aSearchRow->get().begin(); 1550cdf0e10cSrcweir for ( ++loopInRow,++existentInSearchRow; // the first column is the bookmark column 1551cdf0e10cSrcweir loopInRow != m_aSelectRow->get().end(); 1552cdf0e10cSrcweir ++loopInRow,++existentInSearchRow) 1553cdf0e10cSrcweir { 1554cdf0e10cSrcweir if ( (*loopInRow)->isBound() && !( *(*loopInRow) == *existentInSearchRow) ) 1555cdf0e10cSrcweir break; 1556cdf0e10cSrcweir } 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir if(loopInRow == m_aSelectRow->get().end()) 1559cdf0e10cSrcweir (m_pFileSet->get())[j] = 0; // Rows match -- Mark for deletion by setting key to 0 1560cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1561cdf0e10cSrcweir else 1562cdf0e10cSrcweir nFound++; 1563cdf0e10cSrcweir #endif 1564cdf0e10cSrcweir } 1565cdf0e10cSrcweir 1566cdf0e10cSrcweir m_pFileSet->get().erase(::std::remove_if(m_pFileSet->get().begin(),m_pFileSet->get().end(), 1567cdf0e10cSrcweir ::std::bind2nd(::std::equal_to<sal_Int32>(),0)) 1568cdf0e10cSrcweir ,m_pFileSet->get().end()); 1569cdf0e10cSrcweir 1570cdf0e10cSrcweir if (bWasSorted) 1571cdf0e10cSrcweir { 1572cdf0e10cSrcweir // Re-sort on original requested order 1573cdf0e10cSrcweir m_aOrderbyColumnNumber = aOrderbyColumnNumberSave; 1574cdf0e10cSrcweir m_aOrderbyAscending.assign(aOrderbyAscendingSave.begin(), aOrderbyAscendingSave.end()); 1575cdf0e10cSrcweir 1576cdf0e10cSrcweir TIntVector aEvaluationKeySet(m_pFileSet->get()); 1577cdf0e10cSrcweir m_pEvaluationKeySet = &aEvaluationKeySet; 1578cdf0e10cSrcweir sortRows(); 1579cdf0e10cSrcweir } 1580cdf0e10cSrcweir else 1581cdf0e10cSrcweir { 1582cdf0e10cSrcweir m_aOrderbyColumnNumber.clear(); 1583cdf0e10cSrcweir m_aOrderbyAscending.clear(); 1584cdf0e10cSrcweir ::std::sort(m_pFileSet->get().begin(),m_pFileSet->get().end()); 1585cdf0e10cSrcweir } 1586cdf0e10cSrcweir } 1587cdf0e10cSrcweir // SetRowCount(m_pFileSet->count()); 1588cdf0e10cSrcweir } 1589cdf0e10cSrcweir } 1590cdf0e10cSrcweir } break; 1591cdf0e10cSrcweir 1592cdf0e10cSrcweir case SQL_STATEMENT_UPDATE: 1593cdf0e10cSrcweir case SQL_STATEMENT_DELETE: 1594cdf0e10cSrcweir // waehrend der Bearbeitung die Anzahl der bearbeiteten Rows zaehlen: 1595cdf0e10cSrcweir m_nRowCountResult = 0; 1596cdf0e10cSrcweir // Vorlaeufig einfach ueber alle Datensaetze iterieren und 1597cdf0e10cSrcweir // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen): 1598cdf0e10cSrcweir { 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir sal_Bool bOK = sal_True; 1601cdf0e10cSrcweir if (m_pEvaluationKeySet) 1602cdf0e10cSrcweir { 1603cdf0e10cSrcweir m_aEvaluateIter = m_pEvaluationKeySet->begin(); 1604cdf0e10cSrcweir bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); 1605cdf0e10cSrcweir 1606cdf0e10cSrcweir } 1607cdf0e10cSrcweir while (bOK) 1608cdf0e10cSrcweir { 1609cdf0e10cSrcweir if (m_pEvaluationKeySet) 1610cdf0e10cSrcweir ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True); 1611cdf0e10cSrcweir else 1612cdf0e10cSrcweir bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True); 1613cdf0e10cSrcweir 1614cdf0e10cSrcweir if (bOK) 1615cdf0e10cSrcweir { 1616cdf0e10cSrcweir m_nRowCountResult++; 1617cdf0e10cSrcweir if(m_pEvaluationKeySet) 1618cdf0e10cSrcweir { 1619cdf0e10cSrcweir ++m_aEvaluateIter; 1620cdf0e10cSrcweir bOK = m_aEvaluateIter == m_pEvaluationKeySet->end(); 1621cdf0e10cSrcweir } 1622cdf0e10cSrcweir } 1623cdf0e10cSrcweir } 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir // Ergebnis von COUNT(*) in nRowCountResult merken. 1626cdf0e10cSrcweir // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser 1627cdf0e10cSrcweir // Anfrage = 1! 1628cdf0e10cSrcweir // DELETEZ(m_pEvaluationKeySet); 1629cdf0e10cSrcweir m_pEvaluationKeySet = NULL; 1630cdf0e10cSrcweir } 1631cdf0e10cSrcweir // SetRowCount(1); 1632cdf0e10cSrcweir break; 1633cdf0e10cSrcweir case SQL_STATEMENT_INSERT: 1634cdf0e10cSrcweir m_nRowCountResult = 0; 1635cdf0e10cSrcweir 1636cdf0e10cSrcweir OSL_ENSURE(m_aAssignValues.isValid(),"No assign values set!"); 1637cdf0e10cSrcweir if(!m_pTable->InsertRow(m_aAssignValues.getBody(), sal_True,m_xColsIdx)) 1638cdf0e10cSrcweir { 1639cdf0e10cSrcweir m_nFilePos = 0; 1640cdf0e10cSrcweir return sal_False; 1641cdf0e10cSrcweir } 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir m_nRowCountResult = 1; 1644cdf0e10cSrcweir break; 1645cdf0e10cSrcweir default: 1646cdf0e10cSrcweir OSL_ENSURE( false, "OResultSet::OpenImpl: unsupported statement type!" ); 1647cdf0e10cSrcweir break; 1648cdf0e10cSrcweir } 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir // FilePos zuruecksetzen 1651cdf0e10cSrcweir m_nFilePos = 0; 1652cdf0e10cSrcweir 1653cdf0e10cSrcweir return sal_True; 1654cdf0e10cSrcweir } 1655cdf0e10cSrcweir //-------------------------------------------------------------------------- 1656cdf0e10cSrcweir Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId() 1657cdf0e10cSrcweir { 1658cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getUnoTunnelImplementationId" ); 1659cdf0e10cSrcweir static ::cppu::OImplementationId * pId = 0; 1660cdf0e10cSrcweir if (! pId) 1661cdf0e10cSrcweir { 1662cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 1663cdf0e10cSrcweir if (! pId) 1664cdf0e10cSrcweir { 1665cdf0e10cSrcweir static ::cppu::OImplementationId aId; 1666cdf0e10cSrcweir pId = &aId; 1667cdf0e10cSrcweir } 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir return pId->getImplementationId(); 1670cdf0e10cSrcweir } 1671cdf0e10cSrcweir 1672cdf0e10cSrcweir // com::sun::star::lang::XUnoTunnel 1673cdf0e10cSrcweir //------------------------------------------------------------------ 1674cdf0e10cSrcweir sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) 1675cdf0e10cSrcweir { 1676cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getSomething" ); 1677cdf0e10cSrcweir return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 1678cdf0e10cSrcweir ? reinterpret_cast< sal_Int64 >( this ) 1679cdf0e10cSrcweir : 0; 1680cdf0e10cSrcweir } 1681cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1682cdf0e10cSrcweir void OResultSet::setBoundedColumns(const OValueRefRow& _rRow, 1683cdf0e10cSrcweir const OValueRefRow& _rSelectRow, 1684cdf0e10cSrcweir const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, 1685cdf0e10cSrcweir const Reference<XIndexAccess>& _xNames, 1686cdf0e10cSrcweir sal_Bool _bSetColumnMapping, 1687cdf0e10cSrcweir const Reference<XDatabaseMetaData>& _xMetaData, 1688cdf0e10cSrcweir ::std::vector<sal_Int32>& _rColMapping) 1689cdf0e10cSrcweir { 1690cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::setBoundedColumns" ); 1691cdf0e10cSrcweir ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers()); 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir Reference<XPropertySet> xTableColumn; 1694cdf0e10cSrcweir ::rtl::OUString sTableColumnName, sSelectColumnRealName; 1695cdf0e10cSrcweir 1696cdf0e10cSrcweir const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); 1697cdf0e10cSrcweir const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME); 1698cdf0e10cSrcweir const ::rtl::OUString sType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE); 1699cdf0e10cSrcweir 1700cdf0e10cSrcweir typedef ::std::map<OSQLColumns::Vector::iterator,sal_Bool> IterMap; 1701cdf0e10cSrcweir IterMap aSelectIters; 1702cdf0e10cSrcweir OValueRefVector::Vector::iterator aRowIter = _rRow->get().begin()+1; 1703cdf0e10cSrcweir for (sal_Int32 i=0; // the first column is the bookmark column 1704cdf0e10cSrcweir aRowIter != _rRow->get().end(); 1705cdf0e10cSrcweir ++i, ++aRowIter 1706cdf0e10cSrcweir ) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir (*aRowIter)->setBound(sal_False); 1709cdf0e10cSrcweir try 1710cdf0e10cSrcweir { 1711cdf0e10cSrcweir // get the table column and it's name 1712cdf0e10cSrcweir _xNames->getByIndex(i) >>= xTableColumn; 1713cdf0e10cSrcweir OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!"); 1714cdf0e10cSrcweir if (xTableColumn.is()) 1715cdf0e10cSrcweir xTableColumn->getPropertyValue(sName) >>= sTableColumnName; 1716cdf0e10cSrcweir else 1717cdf0e10cSrcweir sTableColumnName = ::rtl::OUString(); 1718cdf0e10cSrcweir 1719cdf0e10cSrcweir // look if we have such a select column 1720cdf0e10cSrcweir // TODO: would like to have a O(log n) search here ... 1721cdf0e10cSrcweir for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin(); 1722cdf0e10cSrcweir aIter != _rxColumns->get().end(); 1723cdf0e10cSrcweir ++aIter 1724cdf0e10cSrcweir ) 1725cdf0e10cSrcweir { 1726cdf0e10cSrcweir if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName)) 1727cdf0e10cSrcweir (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName; 1728cdf0e10cSrcweir else 1729cdf0e10cSrcweir (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName; 1730cdf0e10cSrcweir 1731cdf0e10cSrcweir if ( aCase(sTableColumnName, sSelectColumnRealName) && !(*aRowIter)->isBound() && aSelectIters.end() == aSelectIters.find(aIter) ) 1732cdf0e10cSrcweir { 1733cdf0e10cSrcweir aSelectIters.insert(IterMap::value_type(aIter,sal_True)); 1734cdf0e10cSrcweir if(_bSetColumnMapping) 1735cdf0e10cSrcweir { 1736cdf0e10cSrcweir sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1; 1737cdf0e10cSrcweir // the getXXX methods are 1-based ... 1738cdf0e10cSrcweir sal_Int32 nTableColumnPos = i + 1; 1739cdf0e10cSrcweir // get first table column is the bookmark column ... 1740cdf0e10cSrcweir _rColMapping[nSelectColumnPos] = nTableColumnPos; 1741cdf0e10cSrcweir (_rSelectRow->get())[nSelectColumnPos] = *aRowIter; 1742cdf0e10cSrcweir } 1743cdf0e10cSrcweir 1744cdf0e10cSrcweir (*aRowIter)->setBound(sal_True); 1745cdf0e10cSrcweir sal_Int32 nType = DataType::OTHER; 1746cdf0e10cSrcweir if (xTableColumn.is()) 1747cdf0e10cSrcweir xTableColumn->getPropertyValue(sType) >>= nType; 1748cdf0e10cSrcweir (*aRowIter)->setTypeKind(nType); 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir break; 1751cdf0e10cSrcweir } 1752cdf0e10cSrcweir } 1753cdf0e10cSrcweir } 1754cdf0e10cSrcweir catch (Exception&) 1755cdf0e10cSrcweir { 1756cdf0e10cSrcweir OSL_ENSURE(sal_False, "OResultSet::setBoundedColumns: caught an Exception!"); 1757cdf0e10cSrcweir } 1758cdf0e10cSrcweir } 1759cdf0e10cSrcweir // in this case we got more select columns as columns exist in the table 1760cdf0e10cSrcweir if ( _bSetColumnMapping && aSelectIters.size() != _rColMapping.size() ) 1761cdf0e10cSrcweir { 1762cdf0e10cSrcweir Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY); 1763cdf0e10cSrcweir Sequence< ::rtl::OUString > aSelectColumns = xNameAccess->getElementNames(); 1764cdf0e10cSrcweir 1765cdf0e10cSrcweir for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin(); 1766cdf0e10cSrcweir aIter != _rxColumns->get().end(); 1767cdf0e10cSrcweir ++aIter 1768cdf0e10cSrcweir ) 1769cdf0e10cSrcweir { 1770cdf0e10cSrcweir if ( aSelectIters.end() == aSelectIters.find(aIter) ) 1771cdf0e10cSrcweir { 1772cdf0e10cSrcweir if ( (*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName) ) 1773cdf0e10cSrcweir (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName; 1774cdf0e10cSrcweir else 1775cdf0e10cSrcweir (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName; 1776cdf0e10cSrcweir 1777cdf0e10cSrcweir if ( xNameAccess->hasByName( sSelectColumnRealName ) ) 1778cdf0e10cSrcweir { 1779cdf0e10cSrcweir aSelectIters.insert(IterMap::value_type(aIter,sal_True)); 1780cdf0e10cSrcweir sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1; 1781cdf0e10cSrcweir const ::rtl::OUString* pBegin = aSelectColumns.getConstArray(); 1782cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + aSelectColumns.getLength(); 1783cdf0e10cSrcweir for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i) 1784cdf0e10cSrcweir { 1785cdf0e10cSrcweir if ( aCase(*pBegin, sSelectColumnRealName) ) 1786cdf0e10cSrcweir { 1787cdf0e10cSrcweir // the getXXX methods are 1-based ... 1788cdf0e10cSrcweir sal_Int32 nTableColumnPos = i + 1; 1789cdf0e10cSrcweir // get first table column is the bookmark column ... 1790cdf0e10cSrcweir _rColMapping[nSelectColumnPos] = nTableColumnPos; 1791cdf0e10cSrcweir (_rSelectRow->get())[nSelectColumnPos] = (_rRow->get())[nTableColumnPos]; 1792cdf0e10cSrcweir break; 1793cdf0e10cSrcweir } 1794cdf0e10cSrcweir } 1795cdf0e10cSrcweir } 1796cdf0e10cSrcweir } 1797cdf0e10cSrcweir } 1798cdf0e10cSrcweir } 1799cdf0e10cSrcweir } 1800cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1801cdf0e10cSrcweir void SAL_CALL OResultSet::acquire() throw() 1802cdf0e10cSrcweir { 1803cdf0e10cSrcweir OResultSet_BASE::acquire(); 1804cdf0e10cSrcweir } 1805cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1806cdf0e10cSrcweir void SAL_CALL OResultSet::release() throw() 1807cdf0e10cSrcweir { 1808cdf0e10cSrcweir OResultSet_BASE::release(); 1809cdf0e10cSrcweir } 1810cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1811cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(RuntimeException) 1812cdf0e10cSrcweir { 1813cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" ); 1814cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); 1815cdf0e10cSrcweir } 1816cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1817cdf0e10cSrcweir void OResultSet::doTableSpecials(const OSQLTable& _xTable) 1818cdf0e10cSrcweir { 1819cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::doTableSpecials" ); 1820cdf0e10cSrcweir Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(_xTable,UNO_QUERY); 1821cdf0e10cSrcweir if(xTunnel.is()) 1822cdf0e10cSrcweir { 1823cdf0e10cSrcweir m_pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) ); 1824cdf0e10cSrcweir if(m_pTable) 1825cdf0e10cSrcweir m_pTable->acquire(); 1826cdf0e10cSrcweir } 1827cdf0e10cSrcweir } 1828cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1829cdf0e10cSrcweir void OResultSet::clearInsertRow() 1830cdf0e10cSrcweir { 1831cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearInsertRow" ); 1832cdf0e10cSrcweir m_aRow->setDeleted(sal_False); // set to false here because this is the new row 1833cdf0e10cSrcweir OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin(); 1834cdf0e10cSrcweir const OValueRefVector::Vector::iterator aEnd = m_aInsertRow->get().end(); 1835cdf0e10cSrcweir for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos) 1836cdf0e10cSrcweir { 1837cdf0e10cSrcweir ORowSetValueDecoratorRef& rValue = (*aIter); 1838cdf0e10cSrcweir if ( rValue->isBound() ) 1839cdf0e10cSrcweir { 1840cdf0e10cSrcweir (m_aRow->get())[nPos]->setValue( (*aIter)->getValue() ); 1841cdf0e10cSrcweir } 1842cdf0e10cSrcweir rValue->setBound(nPos == 0); 1843cdf0e10cSrcweir rValue->setModified(sal_False); 1844cdf0e10cSrcweir rValue->setNull(); 1845cdf0e10cSrcweir } 1846cdf0e10cSrcweir } 1847cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1848cdf0e10cSrcweir void OResultSet::initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount) 1849cdf0e10cSrcweir { 1850cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::initializeRow" ); 1851cdf0e10cSrcweir if(!_rRow.isValid()) 1852cdf0e10cSrcweir { 1853cdf0e10cSrcweir _rRow = new OValueRefVector(_nColumnCount); 1854cdf0e10cSrcweir (_rRow->get())[0]->setBound(sal_True); 1855cdf0e10cSrcweir ::std::for_each(_rRow->get().begin()+1,_rRow->get().end(),TSetRefBound(sal_False)); 1856cdf0e10cSrcweir } 1857cdf0e10cSrcweir } 1858cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1859cdf0e10cSrcweir sal_Bool OResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/) 1860cdf0e10cSrcweir { 1861cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::fillIndexValues" ); 1862cdf0e10cSrcweir return sal_False; 1863cdf0e10cSrcweir } 1864cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1865cdf0e10cSrcweir sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData) 1866cdf0e10cSrcweir { 1867cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::move" ); 1868cdf0e10cSrcweir return Move(_eCursorPosition,_nOffset,_bRetrieveData); 1869cdf0e10cSrcweir } 1870cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1871cdf0e10cSrcweir sal_Int32 OResultSet::getDriverPos() const 1872cdf0e10cSrcweir { 1873cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDriverPos" ); 1874cdf0e10cSrcweir return (m_aRow->get())[0]->getValue(); 1875cdf0e10cSrcweir } 1876cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1877cdf0e10cSrcweir sal_Bool OResultSet::deletedVisible() const 1878cdf0e10cSrcweir { 1879cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deletedVisible" ); 1880cdf0e10cSrcweir return m_bShowDeleted; 1881cdf0e10cSrcweir } 1882cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1883cdf0e10cSrcweir sal_Bool OResultSet::isRowDeleted() const 1884cdf0e10cSrcweir { 1885cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isRowDeleted" ); 1886cdf0e10cSrcweir return m_aRow->isDeleted(); 1887cdf0e10cSrcweir } 1888cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1889cdf0e10cSrcweir void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException) 1890cdf0e10cSrcweir { 1891cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" ); 1892cdf0e10cSrcweir // Reference<XInterface> xInt = m_pTable; 1893cdf0e10cSrcweir Reference<XPropertySet> xProp = m_pTable; 1894cdf0e10cSrcweir if(m_pTable && Source.Source == xProp) 1895cdf0e10cSrcweir { 1896cdf0e10cSrcweir m_pTable->release(); 1897cdf0e10cSrcweir m_pTable = NULL; 1898cdf0e10cSrcweir } 1899cdf0e10cSrcweir } 1900cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1901