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