1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "odbc/OResultSet.hxx"
27cdf0e10cSrcweir #include "odbc/OTools.hxx"
28cdf0e10cSrcweir #include "odbc/OResultSetMetaData.hxx"
29cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/CompareBookmark.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
33cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
35cdf0e10cSrcweir #include <comphelper/property.hxx>
36cdf0e10cSrcweir #include <comphelper/sequence.hxx>
37cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
38cdf0e10cSrcweir #include <comphelper/extract.hxx>
39cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
40cdf0e10cSrcweir #include <comphelper/types.hxx>
41cdf0e10cSrcweir #include "connectivity/dbtools.hxx"
42cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
43cdf0e10cSrcweir #include "diagnose_ex.h"
44cdf0e10cSrcweir #include <rtl/logfile.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir using namespace ::comphelper;
47cdf0e10cSrcweir using namespace connectivity;
48cdf0e10cSrcweir using namespace connectivity::odbc;
49cdf0e10cSrcweir using namespace cppu;
50cdf0e10cSrcweir using namespace com::sun::star::uno;
51cdf0e10cSrcweir using namespace com::sun::star::lang;
52cdf0e10cSrcweir using namespace com::sun::star::beans;
53cdf0e10cSrcweir using namespace com::sun::star::sdbc;
54cdf0e10cSrcweir using namespace com::sun::star::sdbcx;
55cdf0e10cSrcweir using namespace com::sun::star::container;
56cdf0e10cSrcweir using namespace com::sun::star::io;
57cdf0e10cSrcweir using namespace com::sun::star::util;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define ODBC_SQL_NOT_DEFINED    99UL
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //------------------------------------------------------------------------------
62cdf0e10cSrcweir //	IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
getImplementationName()63cdf0e10cSrcweir ::rtl::OUString SAL_CALL OResultSet::getImplementationName(  ) throw ( RuntimeException)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.odbc.ResultSet");
66cdf0e10cSrcweir }
67cdf0e10cSrcweir // -------------------------------------------------------------------------
getSupportedServiceNames()68cdf0e10cSrcweir  Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames(  ) throw( RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	 Sequence< ::rtl::OUString > aSupported(2);
71cdf0e10cSrcweir 	aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
72cdf0e10cSrcweir 	aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
73cdf0e10cSrcweir 	return aSupported;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir // -------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)76cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
79cdf0e10cSrcweir 	const ::rtl::OUString* pSupported = aSupported.getConstArray();
80cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
81cdf0e10cSrcweir 	for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
82cdf0e10cSrcweir 		;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	return pSupported != pEnd;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir // -------------------------------------------------------------------------
OResultSet(SQLHANDLE _pStatementHandle,OStatement_Base * pStmt)88cdf0e10cSrcweir OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :	OResultSet_BASE(m_aMutex)
89cdf0e10cSrcweir 						,OPropertySetHelper(OResultSet_BASE::rBHelper)
90cdf0e10cSrcweir                         ,m_aStatementHandle(_pStatementHandle)
91cdf0e10cSrcweir                         ,m_aConnectionHandle(pStmt->getConnectionHandle())
92cdf0e10cSrcweir                         ,m_pStatement(pStmt)
93cdf0e10cSrcweir                         ,m_pSkipDeletedSet(NULL)
94cdf0e10cSrcweir                         ,m_xStatement(*pStmt)
95cdf0e10cSrcweir                         ,m_xMetaData(NULL)
96cdf0e10cSrcweir                         ,m_pRowStatusArray( NULL )
97cdf0e10cSrcweir                         ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
98cdf0e10cSrcweir 						,m_nRowPos(0)
99cdf0e10cSrcweir                         ,m_nLastColumnPos(0)
100cdf0e10cSrcweir                         ,m_nUseBookmarks(ODBC_SQL_NOT_DEFINED)
101cdf0e10cSrcweir                         ,m_nCurrentFetchState(0)
102cdf0e10cSrcweir                         ,m_bWasNull(sal_True)
103cdf0e10cSrcweir                         ,m_bEOF(sal_True)
104cdf0e10cSrcweir 						,m_bLastRecord(sal_False)
105cdf0e10cSrcweir 						,m_bFreeHandle(sal_False)
106cdf0e10cSrcweir 						,m_bInserting(sal_False)
107cdf0e10cSrcweir                         ,m_bFetchData(sal_True)
108cdf0e10cSrcweir 						,m_bRowInserted(sal_False)
109cdf0e10cSrcweir 						,m_bRowDeleted(sal_False)
110cdf0e10cSrcweir 						,m_bUseFetchScroll(sal_False)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	osl_incrementInterlockedCount( &m_refCount );
113cdf0e10cSrcweir 	try
114cdf0e10cSrcweir 	{
115cdf0e10cSrcweir 		m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
116cdf0e10cSrcweir 		N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
117cdf0e10cSrcweir 	}
118cdf0e10cSrcweir 	catch(Exception&)
119cdf0e10cSrcweir 	{ // we don't want our result destroy here
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 	SQLINTEGER nCurType = 0;
122cdf0e10cSrcweir 	try
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 		N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
125cdf0e10cSrcweir 		SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,sal_False);
126cdf0e10cSrcweir 		if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
127cdf0e10cSrcweir 			(nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)
128cdf0e10cSrcweir 			m_pSkipDeletedSet = new OSkipDeletedSet(this);
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir 	catch(Exception&)
131cdf0e10cSrcweir 	{ // we don't want our result destroy here
132cdf0e10cSrcweir 	}
133cdf0e10cSrcweir 	try
134cdf0e10cSrcweir 	{
135cdf0e10cSrcweir 		SQLUINTEGER nValueLen = 0;
136cdf0e10cSrcweir 		OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_GETDATA_EXTENSIONS,nValueLen,NULL);
137cdf0e10cSrcweir 		m_bFetchData = !((SQL_GD_ANY_ORDER & nValueLen) == SQL_GD_ANY_ORDER && nCurType != SQL_CURSOR_FORWARD_ONLY);
138cdf0e10cSrcweir 	}
139cdf0e10cSrcweir 	catch(Exception&)
140cdf0e10cSrcweir 	{ // we don't want our result destroy here
141cdf0e10cSrcweir 		m_bFetchData = sal_True;
142cdf0e10cSrcweir 	}
143cdf0e10cSrcweir 	try
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		if ( getOdbcFunction(ODBC3SQLGetFunctions) )
146cdf0e10cSrcweir 		{
147cdf0e10cSrcweir 			SQLUSMALLINT nSupported = 0;
148cdf0e10cSrcweir 			m_bUseFetchScroll = ( N3SQLGetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 );
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 	}
151cdf0e10cSrcweir 	catch(Exception&)
152cdf0e10cSrcweir 	{
153cdf0e10cSrcweir 		m_bUseFetchScroll = sal_False;
154cdf0e10cSrcweir 	}
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	osl_decrementInterlockedCount( &m_refCount );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir // -------------------------------------------------------------------------
~OResultSet()159cdf0e10cSrcweir OResultSet::~OResultSet()
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	delete [] m_pRowStatusArray;
162cdf0e10cSrcweir 	delete m_pSkipDeletedSet;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir // -----------------------------------------------------------------------------
construct()165cdf0e10cSrcweir void OResultSet::construct()
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	osl_incrementInterlockedCount( &m_refCount );
168cdf0e10cSrcweir 	allocBuffer();
169cdf0e10cSrcweir 	osl_decrementInterlockedCount( &m_refCount );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(void)172cdf0e10cSrcweir void OResultSet::disposing(void)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	SQLRETURN nRet = N3SQLCloseCursor(m_aStatementHandle);
175cdf0e10cSrcweir     OSL_UNUSED( nRet );
176cdf0e10cSrcweir 	OPropertySetHelper::disposing();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
179cdf0e10cSrcweir 	if(!m_aBindVector.empty())
180cdf0e10cSrcweir 		releaseBuffer();
181cdf0e10cSrcweir 	if(m_bFreeHandle)
182cdf0e10cSrcweir 		m_pStatement->getOwnConnection()->freeStatementHandle(m_aStatementHandle);
183cdf0e10cSrcweir 
184cdf0e10cSrcweir m_xStatement.clear();
185cdf0e10cSrcweir m_xMetaData.clear();
186cdf0e10cSrcweir }
187cdf0e10cSrcweir // -------------------------------------------------------------------------
unbind(sal_Bool _bUnbindHandle)188cdf0e10cSrcweir SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::unbind" );
191cdf0e10cSrcweir 	SQLRETURN nRet = 0;
192cdf0e10cSrcweir 	if ( _bUnbindHandle )
193cdf0e10cSrcweir 		nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND);
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	if ( m_aBindVector.size() > 1 )
196cdf0e10cSrcweir 	{
197cdf0e10cSrcweir 		TVoidVector::iterator pValue = m_aBindVector.begin() + 1;
198cdf0e10cSrcweir 		TVoidVector::iterator pEnd = m_aBindVector.end();
199cdf0e10cSrcweir 		for(; pValue != pEnd; ++pValue)
200cdf0e10cSrcweir 		{
201cdf0e10cSrcweir 			switch (pValue->second)
202cdf0e10cSrcweir 			{
203cdf0e10cSrcweir 				case DataType::CHAR:
204cdf0e10cSrcweir 				case DataType::VARCHAR:
205cdf0e10cSrcweir 					delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
206cdf0e10cSrcweir 					break;
207cdf0e10cSrcweir 				case DataType::BIGINT:
208cdf0e10cSrcweir 					delete static_cast< sal_Int64* >(reinterpret_cast< void * >(pValue->first));
209cdf0e10cSrcweir 					break;
210cdf0e10cSrcweir 				case DataType::DECIMAL:
211cdf0e10cSrcweir 				case DataType::NUMERIC:
212cdf0e10cSrcweir 					delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
213cdf0e10cSrcweir 					break;
214cdf0e10cSrcweir 				case DataType::REAL:
215cdf0e10cSrcweir 				case DataType::DOUBLE:
216cdf0e10cSrcweir 					delete static_cast< double* >(reinterpret_cast< void * >(pValue->first));
217cdf0e10cSrcweir 					break;
218cdf0e10cSrcweir 				case DataType::LONGVARCHAR:
219cdf0e10cSrcweir 				case DataType::CLOB:
220cdf0e10cSrcweir 					delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
221cdf0e10cSrcweir 					break;
222cdf0e10cSrcweir 				case DataType::LONGVARBINARY:
223cdf0e10cSrcweir 				case DataType::BLOB:
224cdf0e10cSrcweir 					delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
225cdf0e10cSrcweir 					break;
226cdf0e10cSrcweir 				case DataType::DATE:
227cdf0e10cSrcweir 					delete static_cast< DATE_STRUCT* >(reinterpret_cast< void * >(pValue->first));
228cdf0e10cSrcweir 					break;
229cdf0e10cSrcweir 				case DataType::TIME:
230cdf0e10cSrcweir 					delete static_cast< TIME_STRUCT* >(reinterpret_cast< void * >(pValue->first));
231cdf0e10cSrcweir 					break;
232cdf0e10cSrcweir 				case DataType::TIMESTAMP:
233cdf0e10cSrcweir 					delete static_cast< TIMESTAMP_STRUCT* >(reinterpret_cast< void * >(pValue->first));
234cdf0e10cSrcweir 					break;
235cdf0e10cSrcweir 				case DataType::BIT:
236cdf0e10cSrcweir 				case DataType::TINYINT:
237cdf0e10cSrcweir 					delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
238cdf0e10cSrcweir 					break;
239cdf0e10cSrcweir 				case DataType::SMALLINT:
240cdf0e10cSrcweir 					delete static_cast< sal_Int16* >(reinterpret_cast< void * >(pValue->first));
241cdf0e10cSrcweir 					break;
242cdf0e10cSrcweir 				case DataType::INTEGER:
243cdf0e10cSrcweir 					delete static_cast< sal_Int32* >(reinterpret_cast< void * >(pValue->first));
244cdf0e10cSrcweir 					break;
245cdf0e10cSrcweir 				case DataType::FLOAT:
246cdf0e10cSrcweir 					delete static_cast< float* >(reinterpret_cast< void * >(pValue->first));
247cdf0e10cSrcweir 					break;
248cdf0e10cSrcweir 				case DataType::BINARY:
249cdf0e10cSrcweir 				case DataType::VARBINARY:
250cdf0e10cSrcweir 					delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
251cdf0e10cSrcweir 					break;
252cdf0e10cSrcweir 			}
253cdf0e10cSrcweir 		}
254cdf0e10cSrcweir 		m_aBindVector.clear();
255cdf0e10cSrcweir 		m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
256cdf0e10cSrcweir 	}
257cdf0e10cSrcweir 	return nRet;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir // -------------------------------------------------------------------------
allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)260cdf0e10cSrcweir TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBindColumn" );
263cdf0e10cSrcweir 	TVoidPtr aPair;
264cdf0e10cSrcweir 	switch (_nType)
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		case DataType::CHAR:
267cdf0e10cSrcweir 		case DataType::VARCHAR:
268cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
269cdf0e10cSrcweir 			break;
270cdf0e10cSrcweir 		case DataType::BIGINT:
271cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int64(0)),_nType);
272cdf0e10cSrcweir 			break;
273cdf0e10cSrcweir 		case DataType::DECIMAL:
274cdf0e10cSrcweir 		case DataType::NUMERIC:
275cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
276cdf0e10cSrcweir 			break;
277cdf0e10cSrcweir 		case DataType::REAL:
278cdf0e10cSrcweir 		case DataType::DOUBLE:
279cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType);
280cdf0e10cSrcweir 			break;
281cdf0e10cSrcweir 		case DataType::LONGVARCHAR:
282cdf0e10cSrcweir 		case DataType::CLOB:
283cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType);  // dient nur zum auffinden
284cdf0e10cSrcweir 			break;
285cdf0e10cSrcweir 		case DataType::LONGVARBINARY:
286cdf0e10cSrcweir 		case DataType::BLOB:
287cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType);  // dient nur zum auffinden
288cdf0e10cSrcweir 			break;
289cdf0e10cSrcweir 		case DataType::DATE:
290cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new DATE_STRUCT),_nType);
291cdf0e10cSrcweir 			break;
292cdf0e10cSrcweir 		case DataType::TIME:
293cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIME_STRUCT),_nType);
294cdf0e10cSrcweir 			break;
295cdf0e10cSrcweir 		case DataType::TIMESTAMP:
296cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIMESTAMP_STRUCT),_nType);
297cdf0e10cSrcweir 			break;
298cdf0e10cSrcweir 		case DataType::BIT:
299cdf0e10cSrcweir 		case DataType::TINYINT:
300cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8(0)),_nType);
301cdf0e10cSrcweir 			break;
302cdf0e10cSrcweir 		case DataType::SMALLINT:
303cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int16(0)),_nType);
304cdf0e10cSrcweir 			break;
305cdf0e10cSrcweir 		case DataType::INTEGER:
306cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int32(0)),_nType);
307cdf0e10cSrcweir 			break;
308cdf0e10cSrcweir 		case DataType::FLOAT:
309cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new float(0)),_nType);
310cdf0e10cSrcweir 			break;
311cdf0e10cSrcweir 		case DataType::BINARY:
312cdf0e10cSrcweir 		case DataType::VARBINARY:
313cdf0e10cSrcweir 			aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8[m_aRow[_nColumnIndex].getSequence().getLength()]),_nType);
314cdf0e10cSrcweir 			break;
315cdf0e10cSrcweir 		default:
316cdf0e10cSrcweir 			OSL_ENSURE(0,"Unknown type");
317cdf0e10cSrcweir 			aPair = TVoidPtr(0,_nType);
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir 	return aPair;
320cdf0e10cSrcweir }
321cdf0e10cSrcweir // -------------------------------------------------------------------------
allocBuffer()322cdf0e10cSrcweir void OResultSet::allocBuffer()
323cdf0e10cSrcweir {
324cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBuffer" );
325cdf0e10cSrcweir 	Reference< XResultSetMetaData > xMeta = getMetaData();
326cdf0e10cSrcweir 	sal_Int32 nLen = xMeta->getColumnCount();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	m_aBindVector.reserve(nLen+1);
329cdf0e10cSrcweir 	m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
330cdf0e10cSrcweir 	m_aRow.resize(nLen+1);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	for(sal_Int32 i = 1;i<=nLen;++i)
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		sal_Int32 nType = xMeta->getColumnType(i);
335cdf0e10cSrcweir 		m_aRow[i].setTypeKind( nType );
336cdf0e10cSrcweir 	}
337cdf0e10cSrcweir 	m_aLengthVector.resize(nLen + 1);
338cdf0e10cSrcweir }
339cdf0e10cSrcweir // -------------------------------------------------------------------------
releaseBuffer()340cdf0e10cSrcweir void OResultSet::releaseBuffer()
341cdf0e10cSrcweir {
342cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::releaseBuffer" );
343cdf0e10cSrcweir 	unbind(sal_False);
344cdf0e10cSrcweir 	m_aLengthVector.clear();
345cdf0e10cSrcweir }
346cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)347cdf0e10cSrcweir Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir 	Any aRet = OPropertySetHelper::queryInterface(rType);
350cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
351cdf0e10cSrcweir }
352cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()353cdf0e10cSrcweir  Sequence<  Type > SAL_CALL OResultSet::getTypes(  ) throw( RuntimeException)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	OTypeCollection aTypes(	::getCppuType( (const  Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
356cdf0e10cSrcweir 												::getCppuType( (const  Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
357cdf0e10cSrcweir 												::getCppuType( (const  Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
360cdf0e10cSrcweir }
361cdf0e10cSrcweir // -------------------------------------------------------------------------
362cdf0e10cSrcweir 
findColumn(const::rtl::OUString & columnName)363cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
366cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	Reference< XResultSetMetaData > xMeta = getMetaData();
372cdf0e10cSrcweir 	sal_Int32 nLen = xMeta->getColumnCount();
373cdf0e10cSrcweir 	sal_Int32 i = 1;
374cdf0e10cSrcweir 	for(;i<=nLen;++i)
375cdf0e10cSrcweir 		if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
376cdf0e10cSrcweir 				columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
377cdf0e10cSrcweir 			break;
378cdf0e10cSrcweir 	return i;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir // -------------------------------------------------------------------------
getBinaryStream(sal_Int32)381cdf0e10cSrcweir Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
384cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	// TODO use getBytes instead of
388cdf0e10cSrcweir 	return NULL;
389cdf0e10cSrcweir }
390cdf0e10cSrcweir // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)391cdf0e10cSrcweir Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
394cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	// TODO use getBytes instead of
398cdf0e10cSrcweir 	return NULL;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir // -----------------------------------------------------------------------------
getValue(sal_Int32 _nColumnIndex,SQLSMALLINT _nType,void * _pValue,SQLINTEGER _rSize)401cdf0e10cSrcweir const ORowSetValue& OResultSet::getValue(sal_Int32 _nColumnIndex,SQLSMALLINT _nType,void* _pValue,SQLINTEGER _rSize)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
404cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
405cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 	if(m_bFetchData)
408cdf0e10cSrcweir 	{
409cdf0e10cSrcweir 		if(_nColumnIndex > m_nLastColumnPos)
410cdf0e10cSrcweir 			fillRow(_nColumnIndex);
411cdf0e10cSrcweir 		return m_aRow[_nColumnIndex];
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 	else
414cdf0e10cSrcweir 		OTools::getValue(m_pStatement->getOwnConnection(),m_aStatementHandle,_nColumnIndex,_nType,m_bWasNull,**this,_pValue,_rSize);
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 	return m_aEmptyValue;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // -------------------------------------------------------------------------
getBoolean(sal_Int32 columnIndex)419cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir 	sal_Int8 nVal(0);
422cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_BIT,&nVal,sizeof nVal);
423cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? (sal_Bool)nVal : (sal_Bool)aValue;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir // -------------------------------------------------------------------------
426cdf0e10cSrcweir 
getByte(sal_Int32 columnIndex)427cdf0e10cSrcweir sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	sal_Int8 nRet(0);
430cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_TINYINT,&nRet,sizeof nRet);
431cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int8)aValue;
432cdf0e10cSrcweir }
433cdf0e10cSrcweir // -------------------------------------------------------------------------
434cdf0e10cSrcweir 
getBytes(sal_Int32 columnIndex)435cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
436cdf0e10cSrcweir {
437cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
440cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
441cdf0e10cSrcweir 
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	if(m_bFetchData)
444cdf0e10cSrcweir 	{
445cdf0e10cSrcweir 		if(columnIndex > m_nLastColumnPos)
446cdf0e10cSrcweir 			fillRow(columnIndex);
447cdf0e10cSrcweir 		Sequence< sal_Int8 > nRet;
448cdf0e10cSrcweir 		switch(m_aRow[columnIndex].getTypeKind())
449cdf0e10cSrcweir 		{
450cdf0e10cSrcweir 			case DataType::BINARY:
451cdf0e10cSrcweir 			case DataType::VARBINARY:
452cdf0e10cSrcweir 			case DataType::LONGVARBINARY:
453cdf0e10cSrcweir 				nRet = m_aRow[columnIndex];
454cdf0e10cSrcweir 				break;
455cdf0e10cSrcweir 			default:
456cdf0e10cSrcweir 			{
457cdf0e10cSrcweir 				::rtl::OUString sRet;
458cdf0e10cSrcweir 				sRet = m_aRow[columnIndex].getString();
459cdf0e10cSrcweir 				nRet = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(sRet.getStr()),sizeof(sal_Unicode)*sRet.getLength());
460cdf0e10cSrcweir 			}
461cdf0e10cSrcweir 		}
462cdf0e10cSrcweir 		return nRet;
463cdf0e10cSrcweir 	}
464cdf0e10cSrcweir 
465cdf0e10cSrcweir     const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
466cdf0e10cSrcweir 
467cdf0e10cSrcweir 	switch(nColumnType)
468cdf0e10cSrcweir 	{
469cdf0e10cSrcweir 		case SQL_WVARCHAR:
470cdf0e10cSrcweir         case SQL_WCHAR:
471cdf0e10cSrcweir         case SQL_WLONGVARCHAR:
472cdf0e10cSrcweir         case SQL_VARCHAR:
473cdf0e10cSrcweir         case SQL_CHAR:
474cdf0e10cSrcweir         case SQL_LONGVARCHAR:
475cdf0e10cSrcweir 		{
476cdf0e10cSrcweir 			::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
477cdf0e10cSrcweir 			return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
478cdf0e10cSrcweir 		}
479cdf0e10cSrcweir         default:
480cdf0e10cSrcweir             ;
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 	return OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
483cdf0e10cSrcweir }
484cdf0e10cSrcweir // -------------------------------------------------------------------------
485cdf0e10cSrcweir 
getDate(sal_Int32 columnIndex)486cdf0e10cSrcweir Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
489cdf0e10cSrcweir 	DATE_STRUCT aDate;
490cdf0e10cSrcweir 	aDate.day	= 0;
491cdf0e10cSrcweir 	aDate.month = 0;
492cdf0e10cSrcweir 	aDate.year	= 0;
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(	columnIndex,
495cdf0e10cSrcweir 							m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,
496cdf0e10cSrcweir 											&aDate,sizeof aDate);
497cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue)  ? Date(aDate.day,aDate.month,aDate.year) : (Date)aValue;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir // -------------------------------------------------------------------------
500cdf0e10cSrcweir 
getDouble(sal_Int32 columnIndex)501cdf0e10cSrcweir double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir 	double nRet(0);
504cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_DOUBLE,&nRet,sizeof nRet);
505cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? nRet : (double)aValue;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir // -------------------------------------------------------------------------
508cdf0e10cSrcweir 
getFloat(sal_Int32 columnIndex)509cdf0e10cSrcweir float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	float nRet(0);
512cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_FLOAT,&nRet,sizeof nRet);
513cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? nRet : (float)aValue;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir // -------------------------------------------------------------------------
516cdf0e10cSrcweir 
getInt(sal_Int32 columnIndex)517cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
518cdf0e10cSrcweir {
519cdf0e10cSrcweir 	sal_Int32 nRet(0);
520cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_LONG,&nRet,sizeof nRet);
521cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int32)aValue;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir // -------------------------------------------------------------------------
524cdf0e10cSrcweir 
getRow()525cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::getRow(  ) throw(SQLException, RuntimeException)
526cdf0e10cSrcweir {
527cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
528cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 	return m_pSkipDeletedSet ? m_pSkipDeletedSet->getMappedPosition(getDriverPos()) : getDriverPos();
531cdf0e10cSrcweir }
532cdf0e10cSrcweir // -------------------------------------------------------------------------
533cdf0e10cSrcweir 
getLong(sal_Int32 columnIndex)534cdf0e10cSrcweir sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	sal_Int64 nRet(0);
537cdf0e10cSrcweir 	try
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir 		const ORowSetValue& aValue = getValue(columnIndex,SQL_C_SBIGINT,&nRet,sizeof nRet);
540cdf0e10cSrcweir 		return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int64)aValue;
541cdf0e10cSrcweir 	}
542cdf0e10cSrcweir 	catch(SQLException&)
543cdf0e10cSrcweir 	{
544cdf0e10cSrcweir 		nRet = getString(columnIndex).toInt64();
545cdf0e10cSrcweir 	}
546cdf0e10cSrcweir 	return nRet;
547cdf0e10cSrcweir }
548cdf0e10cSrcweir // -------------------------------------------------------------------------
549cdf0e10cSrcweir 
getMetaData()550cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
551cdf0e10cSrcweir {
552cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
553cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
554cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 
557cdf0e10cSrcweir 	if(!m_xMetaData.is())
558cdf0e10cSrcweir 		m_xMetaData = new OResultSetMetaData(m_pStatement->getOwnConnection(),m_aStatementHandle);
559cdf0e10cSrcweir 	return m_xMetaData;
560cdf0e10cSrcweir }
561cdf0e10cSrcweir // -------------------------------------------------------------------------
getArray(sal_Int32)562cdf0e10cSrcweir Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
563cdf0e10cSrcweir {
564cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
565cdf0e10cSrcweir 	return NULL;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir // -------------------------------------------------------------------------
569cdf0e10cSrcweir 
getClob(sal_Int32)570cdf0e10cSrcweir Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
571cdf0e10cSrcweir {
572cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
573cdf0e10cSrcweir 	return NULL;
574cdf0e10cSrcweir }
575cdf0e10cSrcweir // -------------------------------------------------------------------------
getBlob(sal_Int32)576cdf0e10cSrcweir Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
579cdf0e10cSrcweir 	return NULL;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir // -------------------------------------------------------------------------
582cdf0e10cSrcweir 
getRef(sal_Int32)583cdf0e10cSrcweir Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
586cdf0e10cSrcweir 	return NULL;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir // -------------------------------------------------------------------------
589cdf0e10cSrcweir 
getObject(sal_Int32 columnIndex,const Reference<::com::sun::star::container::XNameAccess> &)590cdf0e10cSrcweir Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
591cdf0e10cSrcweir {
592cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
593cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
594cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	fillRow(columnIndex);
597cdf0e10cSrcweir 	return m_aRow[columnIndex].makeAny();
598cdf0e10cSrcweir }
599cdf0e10cSrcweir // -------------------------------------------------------------------------
600cdf0e10cSrcweir 
getShort(sal_Int32 columnIndex)601cdf0e10cSrcweir sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
602cdf0e10cSrcweir {
603cdf0e10cSrcweir 	sal_Int16 nRet(0);
604cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,SQL_C_SHORT,&nRet,sizeof nRet);
605cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int16)aValue;
606cdf0e10cSrcweir }
607cdf0e10cSrcweir // -------------------------------------------------------------------------
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 
getString(sal_Int32 columnIndex)610cdf0e10cSrcweir ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
611cdf0e10cSrcweir {
612cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getString" );
613cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	::rtl::OUString nRet;
616cdf0e10cSrcweir 	if ( m_bFetchData )
617cdf0e10cSrcweir 		nRet = getValue(columnIndex,0,NULL,0);
618cdf0e10cSrcweir 	else
619cdf0e10cSrcweir     {
620cdf0e10cSrcweir         checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
621cdf0e10cSrcweir         const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
622cdf0e10cSrcweir 		nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
623cdf0e10cSrcweir     }
624cdf0e10cSrcweir 	return nRet;
625cdf0e10cSrcweir }
626cdf0e10cSrcweir // -------------------------------------------------------------------------
627cdf0e10cSrcweir 
getTime(sal_Int32 columnIndex)628cdf0e10cSrcweir Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
629cdf0e10cSrcweir {
630cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
631cdf0e10cSrcweir 	TIME_STRUCT aTime={0,0,0};
632cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,
633cdf0e10cSrcweir 		m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,
634cdf0e10cSrcweir 		&aTime,sizeof aTime);
635cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue) ? Time(0,aTime.second,aTime.minute,aTime.hour) : (Time)aValue;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir // -------------------------------------------------------------------------
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 
getTimestamp(sal_Int32 columnIndex)640cdf0e10cSrcweir DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
641cdf0e10cSrcweir {
642cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
643cdf0e10cSrcweir 	TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
644cdf0e10cSrcweir 	const ORowSetValue& aValue = getValue(columnIndex,
645cdf0e10cSrcweir 		m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,
646cdf0e10cSrcweir 		&aTime,sizeof aTime);
647cdf0e10cSrcweir 	return (&aValue == &m_aEmptyValue)
648cdf0e10cSrcweir 			?
649cdf0e10cSrcweir 			DateTime(static_cast<sal_uInt16>(aTime.fraction*1000),aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year)
650cdf0e10cSrcweir 			:
651cdf0e10cSrcweir 			(DateTime)aValue;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir // -------------------------------------------------------------------------
654cdf0e10cSrcweir 
isBeforeFirst()655cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException)
656cdf0e10cSrcweir {
657cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
658cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
659cdf0e10cSrcweir 	return m_nRowPos == 0;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir // -------------------------------------------------------------------------
isAfterLast()662cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isAfterLast(  ) throw(SQLException, RuntimeException)
663cdf0e10cSrcweir {
664cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
665cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
666cdf0e10cSrcweir 
667cdf0e10cSrcweir 	return m_nRowPos != 0 && m_nCurrentFetchState == SQL_NO_DATA;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir // -------------------------------------------------------------------------
isFirst()670cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isFirst(  ) throw(SQLException, RuntimeException)
671cdf0e10cSrcweir {
672cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
673cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	return m_nRowPos == 1;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir // -------------------------------------------------------------------------
isLast()678cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::isLast(  ) throw(SQLException, RuntimeException)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
681cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 	return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir // -------------------------------------------------------------------------
beforeFirst()687cdf0e10cSrcweir void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
690cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
691cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 	if(first())
695cdf0e10cSrcweir 		previous();
696cdf0e10cSrcweir 	m_nCurrentFetchState = SQL_SUCCESS;
697cdf0e10cSrcweir }
698cdf0e10cSrcweir // -------------------------------------------------------------------------
afterLast()699cdf0e10cSrcweir void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException)
700cdf0e10cSrcweir {
701cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
702cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
703cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
704cdf0e10cSrcweir 
705cdf0e10cSrcweir 	if(last())
706cdf0e10cSrcweir 		next();
707cdf0e10cSrcweir 	m_bEOF = sal_True;
708cdf0e10cSrcweir }
709cdf0e10cSrcweir // -------------------------------------------------------------------------
710cdf0e10cSrcweir 
close()711cdf0e10cSrcweir void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
712cdf0e10cSrcweir {
713cdf0e10cSrcweir 	{
714cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aMutex );
715cdf0e10cSrcweir 		checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 	}
718cdf0e10cSrcweir 	dispose();
719cdf0e10cSrcweir }
720cdf0e10cSrcweir // -------------------------------------------------------------------------
721cdf0e10cSrcweir 
first()722cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException)
723cdf0e10cSrcweir {
724cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::first" );
725cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::FIRST,0,sal_True);
726cdf0e10cSrcweir }
727cdf0e10cSrcweir // -------------------------------------------------------------------------
728cdf0e10cSrcweir 
last()729cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException)
730cdf0e10cSrcweir {
731cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::last" );
732cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::LAST,0,sal_True);
733cdf0e10cSrcweir }
734cdf0e10cSrcweir // -------------------------------------------------------------------------
absolute(sal_Int32 row)735cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
738cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::ABSOLUTE,row,sal_True);
739cdf0e10cSrcweir }
740cdf0e10cSrcweir // -------------------------------------------------------------------------
relative(sal_Int32 row)741cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::relative" );
744cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::RELATIVE,row,sal_True);
745cdf0e10cSrcweir }
746cdf0e10cSrcweir // -------------------------------------------------------------------------
previous()747cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::previous" );
750cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::PRIOR,0,sal_True);
751cdf0e10cSrcweir }
752cdf0e10cSrcweir // -------------------------------------------------------------------------
getStatement()753cdf0e10cSrcweir Reference< XInterface > SAL_CALL OResultSet::getStatement(  ) throw(SQLException, RuntimeException)
754cdf0e10cSrcweir {
755cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
756cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
757cdf0e10cSrcweir 	return m_xStatement;
758cdf0e10cSrcweir }
759cdf0e10cSrcweir // -------------------------------------------------------------------------
760cdf0e10cSrcweir 
rowDeleted()761cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowDeleted() throw(SQLException, RuntimeException)
762cdf0e10cSrcweir {
763cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
764cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
765cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
766cdf0e10cSrcweir 
767cdf0e10cSrcweir 	sal_Bool bRet = m_bRowDeleted;
768cdf0e10cSrcweir 	m_bRowDeleted = sal_False;
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	return bRet;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir // -------------------------------------------------------------------------
rowInserted()773cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
776cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
777cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 	sal_Bool bInserted = m_bRowInserted;
780cdf0e10cSrcweir 	m_bRowInserted = sal_False;
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 	return bInserted;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir // -------------------------------------------------------------------------
rowUpdated()785cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException)
786cdf0e10cSrcweir {
787cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
788cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
789cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 	return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
793cdf0e10cSrcweir }
794cdf0e10cSrcweir // -------------------------------------------------------------------------
795cdf0e10cSrcweir 
next()796cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::next" );
799cdf0e10cSrcweir 	return moveImpl(IResultSetHelper::NEXT,1,sal_True);
800cdf0e10cSrcweir }
801cdf0e10cSrcweir // -------------------------------------------------------------------------
802cdf0e10cSrcweir 
wasNull()803cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
804cdf0e10cSrcweir {
805cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
806cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
807cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 
810cdf0e10cSrcweir 	return m_bFetchData ? m_aRow[m_nLastColumnPos].isNull() : m_bWasNull;
811cdf0e10cSrcweir }
812cdf0e10cSrcweir // -------------------------------------------------------------------------
813cdf0e10cSrcweir 
cancel()814cdf0e10cSrcweir void SAL_CALL OResultSet::cancel(  ) throw(RuntimeException)
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
817cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
818cdf0e10cSrcweir 
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
821cdf0e10cSrcweir }
822cdf0e10cSrcweir // -------------------------------------------------------------------------
clearWarnings()823cdf0e10cSrcweir void SAL_CALL OResultSet::clearWarnings(  ) throw(SQLException, RuntimeException)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir }
826cdf0e10cSrcweir // -------------------------------------------------------------------------
getWarnings()827cdf0e10cSrcweir Any SAL_CALL OResultSet::getWarnings(  ) throw(SQLException, RuntimeException)
828cdf0e10cSrcweir {
829cdf0e10cSrcweir 	return Any();
830cdf0e10cSrcweir }
831cdf0e10cSrcweir // -------------------------------------------------------------------------
insertRow()832cdf0e10cSrcweir void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
833cdf0e10cSrcweir {
834cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
835cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
836cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 	SQLLEN nMaxLen = 20;
840cdf0e10cSrcweir 	SQLLEN nRealLen = 0;
841cdf0e10cSrcweir 	Sequence<sal_Int8> aBookmark(nMaxLen);
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 	SQLRETURN nRet = N3SQLBindCol(m_aStatementHandle,
844cdf0e10cSrcweir 								0,
845cdf0e10cSrcweir 								SQL_C_VARBOOKMARK,
846cdf0e10cSrcweir 								aBookmark.getArray(),
847cdf0e10cSrcweir 								nMaxLen,
848cdf0e10cSrcweir 								&nRealLen
849cdf0e10cSrcweir 								);
850cdf0e10cSrcweir 	//	Sequence<sal_Int8> aRealBookmark(nMaxLen);
851cdf0e10cSrcweir 
852cdf0e10cSrcweir     sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
853cdf0e10cSrcweir 	if ( bPositionByBookmark )
854cdf0e10cSrcweir 	{
855cdf0e10cSrcweir         nRet = N3SQLBulkOperations( m_aStatementHandle, SQL_ADD );
856cdf0e10cSrcweir         fillNeededData( nRet );
857cdf0e10cSrcweir 	}
858cdf0e10cSrcweir 	else
859cdf0e10cSrcweir 	{
860cdf0e10cSrcweir 		if(isBeforeFirst())
861cdf0e10cSrcweir 			next(); // must be done
862cdf0e10cSrcweir         nRet = N3SQLSetPos( m_aStatementHandle, 1, SQL_ADD, SQL_LOCK_NO_CHANGE );
863cdf0e10cSrcweir         fillNeededData( nRet );
864cdf0e10cSrcweir 	}
865cdf0e10cSrcweir 	try
866cdf0e10cSrcweir 	{
867cdf0e10cSrcweir 		OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
868cdf0e10cSrcweir 	}
869cdf0e10cSrcweir 	catch(SQLException e)
870cdf0e10cSrcweir 	{
871cdf0e10cSrcweir 		nRet = unbind();
872cdf0e10cSrcweir 		throw;
873cdf0e10cSrcweir 	}
874cdf0e10cSrcweir 
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 	if ( bPositionByBookmark )
877cdf0e10cSrcweir 	{
878cdf0e10cSrcweir 		nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,aBookmark.getArray(),SQL_IS_POINTER); // SQL_LEN_BINARY_ATTR(aBookmark.getLength())
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 		nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
881cdf0e10cSrcweir 	}
882cdf0e10cSrcweir 	else
883cdf0e10cSrcweir 		nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); // OJ 06.03.2004
884cdf0e10cSrcweir 	// sometimes we got an error but we are not interested in anymore #106047# OJ
885cdf0e10cSrcweir 	//	OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
886cdf0e10cSrcweir 	nRet = unbind();
887cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	if(m_pSkipDeletedSet)
890cdf0e10cSrcweir 	{
891cdf0e10cSrcweir 		aBookmark.realloc(nRealLen);
892cdf0e10cSrcweir 		if(moveToBookmark(makeAny(aBookmark)))
893cdf0e10cSrcweir 		{
894cdf0e10cSrcweir 			sal_Int32 nRowPos = getDriverPos();
895cdf0e10cSrcweir 			if ( -1 == m_nRowPos )
896cdf0e10cSrcweir 			{
897cdf0e10cSrcweir 				nRowPos = m_aPosToBookmarks.size() + 1;
898cdf0e10cSrcweir 			}
899cdf0e10cSrcweir 			if ( nRowPos == m_nRowPos )
900cdf0e10cSrcweir 				++nRowPos;
901cdf0e10cSrcweir 			m_nRowPos = nRowPos;
902cdf0e10cSrcweir 			m_pSkipDeletedSet->insertNewPosition(nRowPos);
903cdf0e10cSrcweir 			m_aPosToBookmarks[aBookmark] = nRowPos;
904cdf0e10cSrcweir 		}
905cdf0e10cSrcweir 	}
906cdf0e10cSrcweir 	m_bRowInserted = sal_True;
907cdf0e10cSrcweir 
908cdf0e10cSrcweir }
909cdf0e10cSrcweir // -------------------------------------------------------------------------
updateRow()910cdf0e10cSrcweir void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
913cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
914cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 	SQLRETURN nRet;
917cdf0e10cSrcweir 
918cdf0e10cSrcweir     sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
919cdf0e10cSrcweir 	if ( bPositionByBookmark )
920cdf0e10cSrcweir 	{
921cdf0e10cSrcweir 		SQLLEN nRealLen = 0;
922cdf0e10cSrcweir 		nRet = N3SQLBindCol(m_aStatementHandle,
923cdf0e10cSrcweir 							0,
924cdf0e10cSrcweir 							SQL_C_VARBOOKMARK,
925cdf0e10cSrcweir 							m_aBookmark.getArray(),
926cdf0e10cSrcweir 							m_aBookmark.getLength(),
927cdf0e10cSrcweir 							&nRealLen
928cdf0e10cSrcweir 							);
929cdf0e10cSrcweir 		fillNeededData(nRet = N3SQLBulkOperations(m_aStatementHandle, SQL_UPDATE_BY_BOOKMARK));
930cdf0e10cSrcweir 	}
931cdf0e10cSrcweir 	else
932cdf0e10cSrcweir 		fillNeededData(nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE));
933cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
934cdf0e10cSrcweir 	// now unbind all columns so we can fetch all columns again with SQLGetData
935cdf0e10cSrcweir 	nRet = unbind();
936cdf0e10cSrcweir 	OSL_ENSURE(nRet == SQL_SUCCESS,"Could not unbind the columns!");
937cdf0e10cSrcweir }
938cdf0e10cSrcweir // -------------------------------------------------------------------------
deleteRow()939cdf0e10cSrcweir void SAL_CALL OResultSet::deleteRow(  ) throw(SQLException, RuntimeException)
940cdf0e10cSrcweir {
941cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
942cdf0e10cSrcweir 	SQLRETURN nRet = SQL_SUCCESS;
943cdf0e10cSrcweir 	sal_Int32 nPos = getDriverPos();
944cdf0e10cSrcweir 	nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE);
945cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
946cdf0e10cSrcweir 
947cdf0e10cSrcweir     m_bRowDeleted = ( m_pRowStatusArray[0] == SQL_ROW_DELETED );
948cdf0e10cSrcweir     if ( m_bRowDeleted )
949cdf0e10cSrcweir 	{
950cdf0e10cSrcweir 		TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
951cdf0e10cSrcweir 		TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
952cdf0e10cSrcweir 		for (; aIter != aEnd; ++aIter)
953cdf0e10cSrcweir 		{
954cdf0e10cSrcweir 			if ( aIter->second == nPos )
955cdf0e10cSrcweir 			{
956cdf0e10cSrcweir 				m_aPosToBookmarks.erase(aIter);
957cdf0e10cSrcweir 				break;
958cdf0e10cSrcweir 			}
959cdf0e10cSrcweir 		}
960cdf0e10cSrcweir 	}
961cdf0e10cSrcweir 	if ( m_pSkipDeletedSet )
962cdf0e10cSrcweir 		m_pSkipDeletedSet->deletePosition(nPos);
963cdf0e10cSrcweir }
964cdf0e10cSrcweir // -------------------------------------------------------------------------
965cdf0e10cSrcweir 
cancelRowUpdates()966cdf0e10cSrcweir void SAL_CALL OResultSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
967cdf0e10cSrcweir {
968cdf0e10cSrcweir }
969cdf0e10cSrcweir // -------------------------------------------------------------------------
970cdf0e10cSrcweir 
moveToInsertRow()971cdf0e10cSrcweir void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
972cdf0e10cSrcweir {
973cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
974cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
975cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
976cdf0e10cSrcweir 
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 	m_nLastColumnPos = 0;
979cdf0e10cSrcweir 	// first unbound all columns
980cdf0e10cSrcweir     OSL_VERIFY_EQUALS( unbind(), SQL_SUCCESS, "Could not unbind columns!" );
981cdf0e10cSrcweir 	//	SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER);
982cdf0e10cSrcweir 	m_bInserting = sal_True;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir // -------------------------------------------------------------------------
985cdf0e10cSrcweir 
moveToCurrentRow()986cdf0e10cSrcweir void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
987cdf0e10cSrcweir {
988cdf0e10cSrcweir 	m_nLastColumnPos = 0;
989cdf0e10cSrcweir }
990cdf0e10cSrcweir // -------------------------------------------------------------------------
updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void * _pValue)991cdf0e10cSrcweir void OResultSet::updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void* _pValue) throw(SQLException, RuntimeException)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
994cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
995cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	m_aBindVector.push_back(allocBindColumn(OTools::MapOdbcType2Jdbc(_nType),columnIndex));
998cdf0e10cSrcweir 	void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
999cdf0e10cSrcweir 	OSL_ENSURE(pData != NULL,"Data for update is NULL!");
1000cdf0e10cSrcweir 	OTools::bindValue(	m_pStatement->getOwnConnection(),
1001cdf0e10cSrcweir 						m_aStatementHandle,
1002cdf0e10cSrcweir 						columnIndex,
1003cdf0e10cSrcweir 						_nType,
1004cdf0e10cSrcweir 						0,
1005cdf0e10cSrcweir 						_pValue,
1006cdf0e10cSrcweir 						pData,
1007cdf0e10cSrcweir 						&m_aLengthVector[columnIndex],
1008cdf0e10cSrcweir 						**this,
1009cdf0e10cSrcweir 						m_nTextEncoding,
1010cdf0e10cSrcweir 						m_pStatement->getOwnConnection()->useOldDateFormat());
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir // -----------------------------------------------------------------------------
updateNull(sal_Int32 columnIndex)1013cdf0e10cSrcweir void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1016cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir 	m_aBindVector.push_back(allocBindColumn(DataType::CHAR,columnIndex));
1019cdf0e10cSrcweir 	void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
1020cdf0e10cSrcweir 	OTools::bindValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_CHAR,0,(sal_Int8*)NULL,pData,&m_aLengthVector[columnIndex],**this,m_nTextEncoding,m_pStatement->getOwnConnection()->useOldDateFormat());
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir // -------------------------------------------------------------------------
1023cdf0e10cSrcweir 
updateBoolean(sal_Int32 columnIndex,sal_Bool x)1024cdf0e10cSrcweir void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir 	updateValue(columnIndex,SQL_BIT,&x);
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir // -------------------------------------------------------------------------
updateByte(sal_Int32 columnIndex,sal_Int8 x)1029cdf0e10cSrcweir void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir 	updateValue(columnIndex,SQL_CHAR,&x);
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir // -------------------------------------------------------------------------
1034cdf0e10cSrcweir 
updateShort(sal_Int32 columnIndex,sal_Int16 x)1035cdf0e10cSrcweir void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir 	updateValue(columnIndex,SQL_TINYINT,&x);
1038cdf0e10cSrcweir }
1039cdf0e10cSrcweir // -------------------------------------------------------------------------
updateInt(sal_Int32 columnIndex,sal_Int32 x)1040cdf0e10cSrcweir void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir 	updateValue(columnIndex,SQL_INTEGER,&x);
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir // -------------------------------------------------------------------------
updateLong(sal_Int32,sal_Int64)1045cdf0e10cSrcweir void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
1046cdf0e10cSrcweir {
1047cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRowUpdate::updateLong", *this );
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir // -----------------------------------------------------------------------
updateFloat(sal_Int32 columnIndex,float x)1050cdf0e10cSrcweir void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
1051cdf0e10cSrcweir {
1052cdf0e10cSrcweir 	updateValue(columnIndex,SQL_REAL,&x);
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir // -------------------------------------------------------------------------
1055cdf0e10cSrcweir 
updateDouble(sal_Int32 columnIndex,double x)1056cdf0e10cSrcweir void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir 	updateValue(columnIndex,SQL_DOUBLE,&x);
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir // -------------------------------------------------------------------------
updateString(sal_Int32 columnIndex,const::rtl::OUString & x)1061cdf0e10cSrcweir void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir 	sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
1064cdf0e10cSrcweir 	SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
1065cdf0e10cSrcweir 	m_aRow[columnIndex] = x;
1066cdf0e10cSrcweir 	m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarchar will be recognized by fillNeededData
1067cdf0e10cSrcweir 	updateValue(columnIndex,nOdbcType,(void*)&x);
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir // -------------------------------------------------------------------------
updateBytes(sal_Int32 columnIndex,const Sequence<sal_Int8> & x)1070cdf0e10cSrcweir void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir 	sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
1073cdf0e10cSrcweir 	SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
1074cdf0e10cSrcweir 	m_aRow[columnIndex] = x;
1075cdf0e10cSrcweir 	m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarbinary will be recognized by fillNeededData
1076cdf0e10cSrcweir 	updateValue(columnIndex,nOdbcType,(void*)&x);
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir // -------------------------------------------------------------------------
updateDate(sal_Int32 columnIndex,const Date & x)1079cdf0e10cSrcweir void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) throw(SQLException, RuntimeException)
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir 	DATE_STRUCT aVal = OTools::DateToOdbcDate(x);
1082cdf0e10cSrcweir 	updateValue(columnIndex,SQL_DATE,&aVal);
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir // -------------------------------------------------------------------------
1085cdf0e10cSrcweir 
updateTime(sal_Int32 columnIndex,const Time & x)1086cdf0e10cSrcweir void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) throw(SQLException, RuntimeException)
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir 	TIME_STRUCT aVal = OTools::TimeToOdbcTime(x);
1089cdf0e10cSrcweir 	updateValue(columnIndex,SQL_TIME,&aVal);
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir // -------------------------------------------------------------------------
1092cdf0e10cSrcweir 
updateTimestamp(sal_Int32 columnIndex,const DateTime & x)1093cdf0e10cSrcweir void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x ) throw(SQLException, RuntimeException)
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir 	TIMESTAMP_STRUCT aVal = OTools::DateTimeToTimestamp(x);
1096cdf0e10cSrcweir 	updateValue(columnIndex,SQL_TIMESTAMP,&aVal);
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir // -------------------------------------------------------------------------
1099cdf0e10cSrcweir 
updateBinaryStream(sal_Int32 columnIndex,const Reference<XInputStream> & x,sal_Int32 length)1100cdf0e10cSrcweir void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir 	if(!x.is())
1103cdf0e10cSrcweir 		::dbtools::throwFunctionSequenceException(*this);
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 	Sequence<sal_Int8> aSeq;
1106cdf0e10cSrcweir 	x->readBytes(aSeq,length);
1107cdf0e10cSrcweir 	updateBytes(columnIndex,aSeq);
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir // -------------------------------------------------------------------------
updateCharacterStream(sal_Int32 columnIndex,const Reference<XInputStream> & x,sal_Int32 length)1110cdf0e10cSrcweir void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir 	updateBinaryStream(columnIndex,x,length);
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshRow()1115cdf0e10cSrcweir void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException)
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
1118cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1119cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	//	SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE);
1123cdf0e10cSrcweir 	m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0);
1124cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir // -------------------------------------------------------------------------
updateObject(sal_Int32 columnIndex,const Any & x)1127cdf0e10cSrcweir void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
1128cdf0e10cSrcweir {
1129cdf0e10cSrcweir 	if (!::dbtools::implUpdateObject(this, columnIndex, x))
1130cdf0e10cSrcweir 		throw SQLException();
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir // -------------------------------------------------------------------------
1133cdf0e10cSrcweir 
updateNumericObject(sal_Int32 columnIndex,const Any & x,sal_Int32)1134cdf0e10cSrcweir void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir 	if (!::dbtools::implUpdateObject(this, columnIndex, x))
1137cdf0e10cSrcweir 		throw SQLException();
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir // -------------------------------------------------------------------------
1140cdf0e10cSrcweir // XRowLocate
getBookmark()1141cdf0e10cSrcweir Any SAL_CALL OResultSet::getBookmark(  ) throw( SQLException,  RuntimeException)
1142cdf0e10cSrcweir {
1143cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
1144cdf0e10cSrcweir 	 ::osl::MutexGuard aGuard( m_aMutex );
1145cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir 	TBookmarkPosMap::iterator aFind = ::std::find_if(m_aPosToBookmarks.begin(),m_aPosToBookmarks.end(),
1148cdf0e10cSrcweir 		::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),m_nRowPos),::std::select2nd<TBookmarkPosMap::value_type>()));
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 	if ( aFind == m_aPosToBookmarks.end() )
1151cdf0e10cSrcweir 	{
1152cdf0e10cSrcweir         if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
1153cdf0e10cSrcweir         {
1154cdf0e10cSrcweir             RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
1155cdf0e10cSrcweir             m_nUseBookmarks = SQL_UB_OFF;
1156cdf0e10cSrcweir 		    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
1157cdf0e10cSrcweir             OSL_UNUSED( nRet );
1158cdf0e10cSrcweir         }
1159cdf0e10cSrcweir 		if(m_nUseBookmarks == SQL_UB_OFF)
1160cdf0e10cSrcweir 			throw SQLException();
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 		m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
1163cdf0e10cSrcweir 		m_aPosToBookmarks[m_aBookmark] = m_nRowPos;
1164cdf0e10cSrcweir 		OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
1165cdf0e10cSrcweir 	}
1166cdf0e10cSrcweir 	else
1167cdf0e10cSrcweir 		m_aBookmark = aFind->first;
1168cdf0e10cSrcweir 	return makeAny(m_aBookmark);
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir // -------------------------------------------------------------------------
moveToBookmark(const Any & bookmark)1171cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::moveToBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException)
1172cdf0e10cSrcweir {
1173cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
1174cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1175cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 	m_nLastColumnPos = 0;
1178cdf0e10cSrcweir 	bookmark >>= m_aBookmark;
1179cdf0e10cSrcweir 	OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
1180cdf0e10cSrcweir 	if(m_aBookmark.getLength())
1181cdf0e10cSrcweir 	{
1182cdf0e10cSrcweir 		SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,m_aBookmark.getArray(),SQL_IS_POINTER); // SQL_LEN_BINARY_ATTR(aBookmark.getLength())
1183cdf0e10cSrcweir         OSL_UNUSED( nReturn );
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir         if ( SQL_INVALID_HANDLE != nReturn && SQL_ERROR != nReturn )
1186cdf0e10cSrcweir         {
1187cdf0e10cSrcweir 		    m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
1188cdf0e10cSrcweir 		    OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1189cdf0e10cSrcweir 		    TBookmarkPosMap::iterator aFind = m_aPosToBookmarks.find(m_aBookmark);
1190cdf0e10cSrcweir 		    if(aFind != m_aPosToBookmarks.end())
1191cdf0e10cSrcweir 			    m_nRowPos = aFind->second;
1192cdf0e10cSrcweir 		    else
1193cdf0e10cSrcweir 			    m_nRowPos = -1;
1194cdf0e10cSrcweir 		    return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
1195cdf0e10cSrcweir         }
1196cdf0e10cSrcweir 	}
1197cdf0e10cSrcweir 	return sal_False;
1198cdf0e10cSrcweir }
1199cdf0e10cSrcweir // -------------------------------------------------------------------------
moveRelativeToBookmark(const Any & bookmark,sal_Int32 rows)1200cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_Int32 rows ) throw( SQLException,  RuntimeException)
1201cdf0e10cSrcweir {
1202cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
1203cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1204cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 	m_nLastColumnPos = 0;
1208cdf0e10cSrcweir 	bookmark >>= m_aBookmark;
1209cdf0e10cSrcweir 	SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,m_aBookmark.getArray(),SQL_IS_POINTER);
1210cdf0e10cSrcweir     OSL_UNUSED( nReturn );
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir 	m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows);
1213cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1214cdf0e10cSrcweir 	return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir // -------------------------------------------------------------------------
compareBookmarks(const Any & lhs,const Any & rhs)1217cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& lhs, const  Any& rhs ) throw( SQLException,  RuntimeException)
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
1220cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1221cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 	return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
1224cdf0e10cSrcweir }
1225cdf0e10cSrcweir // -------------------------------------------------------------------------
hasOrderedBookmarks()1226cdf0e10cSrcweir sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks(  ) throw( SQLException,  RuntimeException)
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir 	return sal_False;
1229cdf0e10cSrcweir }
1230cdf0e10cSrcweir // -------------------------------------------------------------------------
hashBookmark(const Any &)1231cdf0e10cSrcweir sal_Int32 SAL_CALL OResultSet::hashBookmark( const  Any& /*bookmark*/ ) throw( SQLException,  RuntimeException)
1232cdf0e10cSrcweir {
1233cdf0e10cSrcweir     ::dbtools::throwFunctionNotSupportedException( "XRowLocate::hashBookmark", *this );
1234cdf0e10cSrcweir     return 0;
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir // -------------------------------------------------------------------------
1237cdf0e10cSrcweir // XDeleteRows
deleteRows(const Sequence<Any> & rows)1238cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const  Sequence<  Any >& rows ) throw( SQLException,  RuntimeException)
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir 	Sequence< sal_Int32 > aRet(rows.getLength());
1241cdf0e10cSrcweir 	sal_Int32 *pRet	= aRet.getArray();
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 	const Any *pBegin	= rows.getConstArray();
1244cdf0e10cSrcweir 	const Any *pEnd		= pBegin + rows.getLength();
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir 	for(;pBegin != pEnd;++pBegin,++pRet)
1247cdf0e10cSrcweir 	{
1248cdf0e10cSrcweir 		try
1249cdf0e10cSrcweir 		{
1250cdf0e10cSrcweir 			if(moveToBookmark(*pBegin))
1251cdf0e10cSrcweir 			{
1252cdf0e10cSrcweir 				deleteRow();
1253cdf0e10cSrcweir 				*pRet = 1;
1254cdf0e10cSrcweir 			}
1255cdf0e10cSrcweir 		}
1256cdf0e10cSrcweir 		catch(SQLException&)
1257cdf0e10cSrcweir 		{
1258cdf0e10cSrcweir 			*pRet = 0;
1259cdf0e10cSrcweir 		}
1260cdf0e10cSrcweir 	}
1261cdf0e10cSrcweir 	return aRet;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetConcurrency() const1264cdf0e10cSrcweir sal_Int32 OResultSet::getResultSetConcurrency() const
1265cdf0e10cSrcweir {
1266cdf0e10cSrcweir 	sal_uInt32 nValue = 0;
1267cdf0e10cSrcweir 	SQLRETURN nReturn = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0);
1268cdf0e10cSrcweir     OSL_UNUSED( nReturn );
1269cdf0e10cSrcweir 	if(SQL_CONCUR_READ_ONLY == nValue)
1270cdf0e10cSrcweir 		nValue = ResultSetConcurrency::READ_ONLY;
1271cdf0e10cSrcweir 	else
1272cdf0e10cSrcweir 		nValue = ResultSetConcurrency::UPDATABLE;
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir 	return nValue;
1275cdf0e10cSrcweir }
1276cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetType() const1277cdf0e10cSrcweir sal_Int32 OResultSet::getResultSetType() const
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir 	sal_uInt32 nValue = 0;
1280cdf0e10cSrcweir 	N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0);
1281cdf0e10cSrcweir 	if(SQL_SENSITIVE == nValue)
1282cdf0e10cSrcweir 		nValue = ResultSetType::SCROLL_SENSITIVE;
1283cdf0e10cSrcweir 	else if(SQL_INSENSITIVE == nValue)
1284cdf0e10cSrcweir 		nValue = ResultSetType::SCROLL_INSENSITIVE;
1285cdf0e10cSrcweir 	else
1286cdf0e10cSrcweir 	{
1287cdf0e10cSrcweir 		SQLINTEGER nCurType = 0;
1288cdf0e10cSrcweir 		N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
1289cdf0e10cSrcweir 		if(SQL_CURSOR_KEYSET_DRIVEN == nCurType)
1290cdf0e10cSrcweir 			nValue = ResultSetType::SCROLL_SENSITIVE;
1291cdf0e10cSrcweir 		else if(SQL_CURSOR_STATIC  == nCurType)
1292cdf0e10cSrcweir 			nValue = ResultSetType::SCROLL_INSENSITIVE;
1293cdf0e10cSrcweir 		else if(SQL_CURSOR_FORWARD_ONLY == nCurType)
1294cdf0e10cSrcweir 			nValue = ResultSetType::FORWARD_ONLY;
1295cdf0e10cSrcweir 		else if(SQL_CURSOR_DYNAMIC == nCurType)
1296cdf0e10cSrcweir 			nValue = ResultSetType::SCROLL_SENSITIVE;
1297cdf0e10cSrcweir 	}
1298cdf0e10cSrcweir 	return nValue;
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchDirection() const1301cdf0e10cSrcweir sal_Int32 OResultSet::getFetchDirection() const
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir 	return FetchDirection::FORWARD;
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchSize() const1306cdf0e10cSrcweir sal_Int32 OResultSet::getFetchSize() const
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir 	sal_uInt32 nValue = 0;
1309cdf0e10cSrcweir 	N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0);
1310cdf0e10cSrcweir 	return nValue;
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir //------------------------------------------------------------------------------
getCursorName() const1313cdf0e10cSrcweir ::rtl::OUString OResultSet::getCursorName() const
1314cdf0e10cSrcweir {
1315cdf0e10cSrcweir 	SQLCHAR pName[258];
1316cdf0e10cSrcweir 	SQLSMALLINT nRealLen = 0;
1317cdf0e10cSrcweir 	N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen);
1318cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii((const char*)pName);
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir // -------------------------------------------------------------------------
isBookmarkable() const1321cdf0e10cSrcweir sal_Bool  OResultSet::isBookmarkable() const
1322cdf0e10cSrcweir {
1323cdf0e10cSrcweir 	if(!m_aConnectionHandle)
1324cdf0e10cSrcweir 		return sal_False;
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir 	sal_uInt32 nValue = 0;
1327cdf0e10cSrcweir 	N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0);
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 	sal_Int32 nAttr = 0;
1330cdf0e10cSrcweir 	try
1331cdf0e10cSrcweir 	{
1332cdf0e10cSrcweir 		switch(nValue)
1333cdf0e10cSrcweir 		{
1334cdf0e10cSrcweir 		case SQL_CURSOR_FORWARD_ONLY:
1335cdf0e10cSrcweir 			return sal_False;
1336cdf0e10cSrcweir 		case SQL_CURSOR_STATIC:
1337cdf0e10cSrcweir 			OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_STATIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
1338cdf0e10cSrcweir 			break;
1339cdf0e10cSrcweir 		case SQL_CURSOR_KEYSET_DRIVEN:
1340cdf0e10cSrcweir 			OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_KEYSET_CURSOR_ATTRIBUTES1,nAttr,NULL);
1341cdf0e10cSrcweir 			break;
1342cdf0e10cSrcweir 		case SQL_CURSOR_DYNAMIC:
1343cdf0e10cSrcweir 			OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
1344cdf0e10cSrcweir 			break;
1345cdf0e10cSrcweir 		}
1346cdf0e10cSrcweir 	}
1347cdf0e10cSrcweir 	catch(Exception&)
1348cdf0e10cSrcweir 	{
1349cdf0e10cSrcweir 		return sal_False;
1350cdf0e10cSrcweir 	}
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir     if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
1353cdf0e10cSrcweir     {
1354cdf0e10cSrcweir         m_nUseBookmarks = SQL_UB_OFF;
1355cdf0e10cSrcweir 	    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
1356cdf0e10cSrcweir         OSL_UNUSED( nRet );
1357cdf0e10cSrcweir     }
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 	return (m_nUseBookmarks != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK;
1360cdf0e10cSrcweir }
1361cdf0e10cSrcweir //------------------------------------------------------------------------------
setFetchDirection(sal_Int32 _par0)1362cdf0e10cSrcweir void OResultSet::setFetchDirection(sal_Int32 _par0)
1363cdf0e10cSrcweir {
1364cdf0e10cSrcweir 	OSL_ENSURE(_par0>0,"Illegal fetch direction!");
1365cdf0e10cSrcweir 	if ( _par0 > 0 )
1366cdf0e10cSrcweir 	{
1367cdf0e10cSrcweir 		N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
1368cdf0e10cSrcweir 	}
1369cdf0e10cSrcweir }
1370cdf0e10cSrcweir //------------------------------------------------------------------------------
setFetchSize(sal_Int32 _par0)1371cdf0e10cSrcweir void OResultSet::setFetchSize(sal_Int32 _par0)
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir 	OSL_ENSURE(_par0>0,"Illegal fetch size!");
1374cdf0e10cSrcweir 	if ( _par0 > 0 )
1375cdf0e10cSrcweir 	{
1376cdf0e10cSrcweir 		N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
1377cdf0e10cSrcweir 		delete m_pRowStatusArray;
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir 		m_pRowStatusArray = new SQLUSMALLINT[_par0];
1380cdf0e10cSrcweir 		N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
1381cdf0e10cSrcweir 	}
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir // -------------------------------------------------------------------------
createArrayHelper() const1384cdf0e10cSrcweir IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
1385cdf0e10cSrcweir {
1386cdf0e10cSrcweir 	Sequence< Property > aProps(6);
1387cdf0e10cSrcweir 	Property* pProperties = aProps.getArray();
1388cdf0e10cSrcweir 	sal_Int32 nPos = 0;
1389cdf0e10cSrcweir 	DECL_PROP1IMPL(CURSORNAME,			::rtl::OUString) PropertyAttribute::READONLY);
1390cdf0e10cSrcweir 	DECL_PROP0(FETCHDIRECTION,			sal_Int32);
1391cdf0e10cSrcweir 	DECL_PROP0(FETCHSIZE,				sal_Int32);
1392cdf0e10cSrcweir 	DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
1393cdf0e10cSrcweir 	DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
1394cdf0e10cSrcweir 	DECL_PROP1IMPL(RESULTSETTYPE,		sal_Int32) PropertyAttribute::READONLY);
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir 	return new OPropertyArrayHelper(aProps);
1397cdf0e10cSrcweir }
1398cdf0e10cSrcweir // -------------------------------------------------------------------------
getInfoHelper()1399cdf0e10cSrcweir IPropertyArrayHelper & OResultSet::getInfoHelper()
1400cdf0e10cSrcweir {
1401cdf0e10cSrcweir 	return *const_cast<OResultSet*>(this)->getArrayHelper();
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir // -------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)1404cdf0e10cSrcweir sal_Bool OResultSet::convertFastPropertyValue(
1405cdf0e10cSrcweir 							Any & rConvertedValue,
1406cdf0e10cSrcweir 							Any & rOldValue,
1407cdf0e10cSrcweir 							sal_Int32 nHandle,
1408cdf0e10cSrcweir 							const Any& rValue )
1409cdf0e10cSrcweir 								throw (::com::sun::star::lang::IllegalArgumentException)
1410cdf0e10cSrcweir {
1411cdf0e10cSrcweir 	switch(nHandle)
1412cdf0e10cSrcweir 	{
1413cdf0e10cSrcweir 		case PROPERTY_ID_ISBOOKMARKABLE:
1414cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
1415cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1416cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
1417cdf0e10cSrcweir 			throw ::com::sun::star::lang::IllegalArgumentException();
1418cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
1419cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
1420cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
1421cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
1422cdf0e10cSrcweir 		default:
1423cdf0e10cSrcweir 			;
1424cdf0e10cSrcweir 	}
1425cdf0e10cSrcweir 	return sal_False;
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)1428cdf0e10cSrcweir void OResultSet::setFastPropertyValue_NoBroadcast(
1429cdf0e10cSrcweir 								sal_Int32 nHandle,
1430cdf0e10cSrcweir 								const Any& rValue
1431cdf0e10cSrcweir 												 )
1432cdf0e10cSrcweir 												 throw (Exception)
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir 	switch(nHandle)
1435cdf0e10cSrcweir 	{
1436cdf0e10cSrcweir 		case PROPERTY_ID_ISBOOKMARKABLE:
1437cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
1438cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1439cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
1440cdf0e10cSrcweir 			throw Exception();
1441cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
1442cdf0e10cSrcweir 			setFetchDirection(getINT32(rValue));
1443cdf0e10cSrcweir 			break;
1444cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
1445cdf0e10cSrcweir 			setFetchSize(getINT32(rValue));
1446cdf0e10cSrcweir 			break;
1447cdf0e10cSrcweir 		default:
1448cdf0e10cSrcweir 			;
1449cdf0e10cSrcweir 	}
1450cdf0e10cSrcweir }
1451cdf0e10cSrcweir // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const1452cdf0e10cSrcweir void OResultSet::getFastPropertyValue(
1453cdf0e10cSrcweir 								Any& rValue,
1454cdf0e10cSrcweir 								sal_Int32 nHandle
1455cdf0e10cSrcweir 									 ) const
1456cdf0e10cSrcweir {
1457cdf0e10cSrcweir 	switch(nHandle)
1458cdf0e10cSrcweir 	{
1459cdf0e10cSrcweir 		case PROPERTY_ID_ISBOOKMARKABLE:
1460cdf0e10cSrcweir 			rValue = bool2any(isBookmarkable());
1461cdf0e10cSrcweir 			break;
1462cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
1463cdf0e10cSrcweir 			rValue <<= getCursorName();
1464cdf0e10cSrcweir 			break;
1465cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
1466cdf0e10cSrcweir 			rValue <<= getResultSetConcurrency();
1467cdf0e10cSrcweir 			break;
1468cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
1469cdf0e10cSrcweir 			rValue <<= getResultSetType();
1470cdf0e10cSrcweir 			break;
1471cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
1472cdf0e10cSrcweir 			rValue <<= getFetchDirection();
1473cdf0e10cSrcweir 			break;
1474cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
1475cdf0e10cSrcweir 			rValue <<= getFetchSize();
1476cdf0e10cSrcweir 			break;
1477cdf0e10cSrcweir 	}
1478cdf0e10cSrcweir }
1479cdf0e10cSrcweir // -------------------------------------------------------------------------
fillRow(sal_Int32 _nToColumn)1480cdf0e10cSrcweir void OResultSet::fillRow(sal_Int32 _nToColumn)
1481cdf0e10cSrcweir {
1482cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillRow" );
1483cdf0e10cSrcweir 	if((sal_Int32)m_aRow.size() <= _nToColumn)
1484cdf0e10cSrcweir 	{
1485cdf0e10cSrcweir 		m_aRow.resize(_nToColumn+1);
1486cdf0e10cSrcweir 		m_aRow[_nToColumn].setBound(sal_True);
1487cdf0e10cSrcweir 	}
1488cdf0e10cSrcweir 	m_bFetchData = sal_False;
1489cdf0e10cSrcweir 
1490cdf0e10cSrcweir 	sal_Int32			nColumn		= m_nLastColumnPos + 1;
1491cdf0e10cSrcweir 	TDataRow::iterator pColumn		= m_aRow.begin() + nColumn;
1492cdf0e10cSrcweir 	TDataRow::iterator pColumnEnd	= m_aRow.begin() + _nToColumn + 1;
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir 	for (; pColumn < pColumnEnd; ++nColumn, ++pColumn)
1495cdf0e10cSrcweir 	{
1496cdf0e10cSrcweir 		const sal_Int32 nType = pColumn->getTypeKind();
1497cdf0e10cSrcweir 		switch (nType)
1498cdf0e10cSrcweir 		{
1499cdf0e10cSrcweir 			case DataType::CHAR:
1500cdf0e10cSrcweir 			case DataType::VARCHAR:
1501cdf0e10cSrcweir             case DataType::DECIMAL:
1502cdf0e10cSrcweir 			case DataType::NUMERIC:
1503cdf0e10cSrcweir             case DataType::LONGVARCHAR:
1504cdf0e10cSrcweir 			case DataType::CLOB:
1505cdf0e10cSrcweir                 {
1506cdf0e10cSrcweir                     const SWORD nColumnType = impl_getColumnType_nothrow(nColumn);
1507cdf0e10cSrcweir 		            *pColumn = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,nColumn,nColumnType,m_bWasNull,**this,m_nTextEncoding);
1508cdf0e10cSrcweir                 }
1509cdf0e10cSrcweir 				break;
1510cdf0e10cSrcweir 			case DataType::BIGINT:
1511cdf0e10cSrcweir 				*pColumn = getLong(nColumn);
1512cdf0e10cSrcweir 				break;
1513cdf0e10cSrcweir 			case DataType::REAL:
1514cdf0e10cSrcweir 			case DataType::DOUBLE:
1515cdf0e10cSrcweir 				*pColumn = getDouble(nColumn);
1516cdf0e10cSrcweir 				break;
1517cdf0e10cSrcweir 			case DataType::LONGVARBINARY:
1518cdf0e10cSrcweir 			case DataType::BLOB:
1519cdf0e10cSrcweir 				*pColumn = getBytes(nColumn);
1520cdf0e10cSrcweir 				break;
1521cdf0e10cSrcweir 			case DataType::DATE:
1522cdf0e10cSrcweir 				*pColumn = getDate(nColumn);
1523cdf0e10cSrcweir 				break;
1524cdf0e10cSrcweir 			case DataType::TIME:
1525cdf0e10cSrcweir 				*pColumn = getTime(nColumn);
1526cdf0e10cSrcweir 				break;
1527cdf0e10cSrcweir 			case DataType::TIMESTAMP:
1528cdf0e10cSrcweir 				*pColumn = getTimestamp(nColumn);
1529cdf0e10cSrcweir 				break;
1530cdf0e10cSrcweir 			case DataType::BIT:
1531cdf0e10cSrcweir 				*pColumn = getBoolean(nColumn);
1532cdf0e10cSrcweir 				break;
1533cdf0e10cSrcweir 			case DataType::TINYINT:
1534cdf0e10cSrcweir 				*pColumn = getByte(nColumn);
1535cdf0e10cSrcweir 				break;
1536cdf0e10cSrcweir 			case DataType::SMALLINT:
1537cdf0e10cSrcweir 				*pColumn = getShort(nColumn);
1538cdf0e10cSrcweir 				break;
1539cdf0e10cSrcweir 			case DataType::INTEGER:
1540cdf0e10cSrcweir 				*pColumn = getInt(nColumn);
1541cdf0e10cSrcweir 				break;
1542cdf0e10cSrcweir 			case DataType::FLOAT:
1543cdf0e10cSrcweir 				*pColumn = getFloat(nColumn);
1544cdf0e10cSrcweir 				break;
1545cdf0e10cSrcweir 			case DataType::BINARY:
1546cdf0e10cSrcweir 			case DataType::VARBINARY:
1547cdf0e10cSrcweir 				*pColumn = getBytes(nColumn);
1548cdf0e10cSrcweir 				break;
1549cdf0e10cSrcweir 		}
1550cdf0e10cSrcweir 
1551cdf0e10cSrcweir 		if ( m_bWasNull )
1552cdf0e10cSrcweir 			pColumn->setNull();
1553cdf0e10cSrcweir 		if(nType != pColumn->getTypeKind())
1554cdf0e10cSrcweir 		{
1555cdf0e10cSrcweir 			pColumn->setTypeKind(nType);
1556cdf0e10cSrcweir 		}
1557cdf0e10cSrcweir 	}
1558cdf0e10cSrcweir 	m_nLastColumnPos = _nToColumn;
1559cdf0e10cSrcweir 	m_bFetchData = sal_True;
1560cdf0e10cSrcweir }
1561cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()1562cdf0e10cSrcweir void SAL_CALL OResultSet::acquire() throw()
1563cdf0e10cSrcweir {
1564cdf0e10cSrcweir 	OResultSet_BASE::acquire();
1565cdf0e10cSrcweir }
1566cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()1567cdf0e10cSrcweir void SAL_CALL OResultSet::release() throw()
1568cdf0e10cSrcweir {
1569cdf0e10cSrcweir 	OResultSet_BASE::release();
1570cdf0e10cSrcweir }
1571cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()1572cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
1573cdf0e10cSrcweir {
1574cdf0e10cSrcweir 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1575cdf0e10cSrcweir }
1576cdf0e10cSrcweir // -----------------------------------------------------------------------------
move(IResultSetHelper::Movement _eCursorPosition,sal_Int32 _nOffset,sal_Bool)1577cdf0e10cSrcweir sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool /*_bRetrieveData*/)
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::move" );
1580cdf0e10cSrcweir 	SQLSMALLINT nFetchOrientation = SQL_FETCH_NEXT;
1581cdf0e10cSrcweir 	switch(_eCursorPosition)
1582cdf0e10cSrcweir 	{
1583cdf0e10cSrcweir 		case IResultSetHelper::NEXT:
1584cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_NEXT;
1585cdf0e10cSrcweir 			break;
1586cdf0e10cSrcweir 		case IResultSetHelper::PRIOR:
1587cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_PRIOR;
1588cdf0e10cSrcweir 			break;
1589cdf0e10cSrcweir 		case IResultSetHelper::FIRST:
1590cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_FIRST;
1591cdf0e10cSrcweir 			break;
1592cdf0e10cSrcweir 		case IResultSetHelper::LAST:
1593cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_LAST;
1594cdf0e10cSrcweir 			break;
1595cdf0e10cSrcweir 		case IResultSetHelper::RELATIVE:
1596cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_RELATIVE;
1597cdf0e10cSrcweir 			break;
1598cdf0e10cSrcweir 		case IResultSetHelper::ABSOLUTE:
1599cdf0e10cSrcweir 			nFetchOrientation = SQL_FETCH_ABSOLUTE;
1600cdf0e10cSrcweir 			break;
1601cdf0e10cSrcweir 		case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
1602cdf0e10cSrcweir 		{
1603cdf0e10cSrcweir 			TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
1604cdf0e10cSrcweir 			TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
1605cdf0e10cSrcweir 			for (; aIter != aEnd; ++aIter)
1606cdf0e10cSrcweir 			{
1607cdf0e10cSrcweir 				if ( aIter->second == _nOffset )
1608cdf0e10cSrcweir 					return moveToBookmark(makeAny(aIter->first));
1609cdf0e10cSrcweir 			}
1610cdf0e10cSrcweir 			OSL_ENSURE(0,"Bookmark not found!");
1611cdf0e10cSrcweir 		}
1612cdf0e10cSrcweir 		return sal_False;
1613cdf0e10cSrcweir 	}
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir 	m_bEOF = sal_False;
1616cdf0e10cSrcweir 	m_nLastColumnPos = 0;
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir 	SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
1619cdf0e10cSrcweir 	if ( !m_bUseFetchScroll && _eCursorPosition == IResultSetHelper::NEXT )
1620cdf0e10cSrcweir 		m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
1621cdf0e10cSrcweir 	else
1622cdf0e10cSrcweir 		m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,nFetchOrientation,_nOffset);
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir 	OSL_TRACE( __FILE__": OSkipDeletedSet::OResultSet::move(%d,%d), FetchState = %d",nFetchOrientation,_nOffset,m_nCurrentFetchState);
1625cdf0e10cSrcweir 	OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir     const bool bSuccess = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
1628cdf0e10cSrcweir 	if ( bSuccess )
1629cdf0e10cSrcweir 	{
1630cdf0e10cSrcweir 		switch(_eCursorPosition)
1631cdf0e10cSrcweir 		{
1632cdf0e10cSrcweir 			case IResultSetHelper::NEXT:
1633cdf0e10cSrcweir 				++m_nRowPos;
1634cdf0e10cSrcweir 				break;
1635cdf0e10cSrcweir 			case IResultSetHelper::PRIOR:
1636cdf0e10cSrcweir 				--m_nRowPos;
1637cdf0e10cSrcweir 				break;
1638cdf0e10cSrcweir 			case IResultSetHelper::FIRST:
1639cdf0e10cSrcweir 				m_nRowPos = 1;
1640cdf0e10cSrcweir 				break;
1641cdf0e10cSrcweir 			case IResultSetHelper::LAST:
1642cdf0e10cSrcweir 				m_bEOF = sal_True;
1643cdf0e10cSrcweir 				break;
1644cdf0e10cSrcweir 			case IResultSetHelper::RELATIVE:
1645cdf0e10cSrcweir 				m_nRowPos += _nOffset;
1646cdf0e10cSrcweir 				break;
1647cdf0e10cSrcweir 			case IResultSetHelper::ABSOLUTE:
1648cdf0e10cSrcweir 			case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
1649cdf0e10cSrcweir 				m_nRowPos = _nOffset;
1650cdf0e10cSrcweir 				break;
1651cdf0e10cSrcweir 		} // switch(_eCursorPosition)
1652cdf0e10cSrcweir         if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
1653cdf0e10cSrcweir         {
1654cdf0e10cSrcweir             RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
1655cdf0e10cSrcweir             m_nUseBookmarks = SQL_UB_OFF;
1656cdf0e10cSrcweir 		    SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
1657cdf0e10cSrcweir             OSL_UNUSED( nRet );
1658cdf0e10cSrcweir         }
1659cdf0e10cSrcweir 		if ( m_nUseBookmarks != SQL_UB_OFF )
1660cdf0e10cSrcweir 		{
1661cdf0e10cSrcweir             RTL_LOGFILE_CONTEXT_TRACE( aLogger, "OTools::getBytesValue" );
1662cdf0e10cSrcweir 			m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
1663cdf0e10cSrcweir 			m_aPosToBookmarks[m_aBookmark] = m_nRowPos;
1664cdf0e10cSrcweir 			OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
1665cdf0e10cSrcweir 		}
1666cdf0e10cSrcweir 	}
1667cdf0e10cSrcweir 	else if ( IResultSetHelper::PRIOR == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA )
1668cdf0e10cSrcweir 		m_nRowPos = 0;
1669cdf0e10cSrcweir 	else if(IResultSetHelper::NEXT == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA)
1670cdf0e10cSrcweir 		++m_nRowPos;
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir 	return bSuccess;
1673cdf0e10cSrcweir }
1674cdf0e10cSrcweir // -----------------------------------------------------------------------------
getDriverPos() const1675cdf0e10cSrcweir sal_Int32 OResultSet::getDriverPos() const
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir 	sal_Int32 nValue = 0;
1678cdf0e10cSrcweir 	SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_NUMBER,&nValue,SQL_IS_UINTEGER,0);
1679cdf0e10cSrcweir     OSL_UNUSED( nRet );
1680cdf0e10cSrcweir 	OSL_TRACE( __FILE__": OResultSet::getDriverPos() = Ret = %d, RowNum = %d, RowPos = %d",nRet,nValue , m_nRowPos);
1681cdf0e10cSrcweir 	return nValue ? nValue : m_nRowPos;
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir // -----------------------------------------------------------------------------
deletedVisible() const1684cdf0e10cSrcweir sal_Bool OResultSet::deletedVisible() const
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir 	return sal_False;
1687cdf0e10cSrcweir }
1688cdf0e10cSrcweir // -----------------------------------------------------------------------------
isRowDeleted() const1689cdf0e10cSrcweir sal_Bool OResultSet::isRowDeleted() const
1690cdf0e10cSrcweir {
1691cdf0e10cSrcweir 	return m_pRowStatusArray[0] == SQL_ROW_DELETED;
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir // -----------------------------------------------------------------------------
moveImpl(IResultSetHelper::Movement _eCursorPosition,sal_Int32 _nOffset,sal_Bool _bRetrieveData)1694cdf0e10cSrcweir sal_Bool OResultSet::moveImpl(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
1695cdf0e10cSrcweir {
1696cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
1697cdf0e10cSrcweir 	checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
1698cdf0e10cSrcweir 	return (m_pSkipDeletedSet != NULL)
1699cdf0e10cSrcweir 				?   m_pSkipDeletedSet->skipDeleted(_eCursorPosition,_nOffset,_bRetrieveData)
1700cdf0e10cSrcweir 				:   move(_eCursorPosition,_nOffset,_bRetrieveData);
1701cdf0e10cSrcweir }
1702cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillNeededData(SQLRETURN _nRet)1703cdf0e10cSrcweir void OResultSet::fillNeededData(SQLRETURN _nRet)
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillNeededData" );
1706cdf0e10cSrcweir 	SQLRETURN nRet = _nRet;
1707cdf0e10cSrcweir 	if( nRet == SQL_NEED_DATA)
1708cdf0e10cSrcweir 	{
1709cdf0e10cSrcweir 		void* pColumnIndex = 0;
1710cdf0e10cSrcweir 		nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir 		do
1713cdf0e10cSrcweir 		{
1714cdf0e10cSrcweir 			if (nRet != SQL_SUCCESS && nRet != SQL_SUCCESS_WITH_INFO && nRet != SQL_NEED_DATA)
1715cdf0e10cSrcweir 				break;
1716cdf0e10cSrcweir 
1717cdf0e10cSrcweir 			sal_IntPtr nColumnIndex ( reinterpret_cast<sal_IntPtr>(pColumnIndex));
1718cdf0e10cSrcweir 			Sequence< sal_Int8 > aSeq;
1719cdf0e10cSrcweir 			switch(m_aRow[nColumnIndex].getTypeKind())
1720cdf0e10cSrcweir 			{
1721cdf0e10cSrcweir 				case DataType::BINARY:
1722cdf0e10cSrcweir 				case DataType::VARBINARY:
1723cdf0e10cSrcweir 				case DataType::LONGVARBINARY:
1724cdf0e10cSrcweir 				case DataType::BLOB:
1725cdf0e10cSrcweir 					aSeq = m_aRow[nColumnIndex];
1726cdf0e10cSrcweir 					N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength());
1727cdf0e10cSrcweir 					break;
1728cdf0e10cSrcweir 				case SQL_WLONGVARCHAR:
1729cdf0e10cSrcweir 				{
1730cdf0e10cSrcweir 					::rtl::OUString sRet;
1731cdf0e10cSrcweir 					sRet = m_aRow[nColumnIndex].getString();
1732cdf0e10cSrcweir 					nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)sRet.getStr(), sizeof(sal_Unicode)*sRet.getLength());
1733cdf0e10cSrcweir 					break;
1734cdf0e10cSrcweir 				}
1735cdf0e10cSrcweir 				case DataType::LONGVARCHAR:
1736cdf0e10cSrcweir 				case DataType::CLOB:
1737cdf0e10cSrcweir 				{
1738cdf0e10cSrcweir 					::rtl::OUString sRet;
1739cdf0e10cSrcweir 					sRet = m_aRow[nColumnIndex].getString();
1740cdf0e10cSrcweir 					::rtl::OString aString(::rtl::OUStringToOString(sRet,m_nTextEncoding));
1741cdf0e10cSrcweir 					nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)aString.getStr(), aString.getLength());
1742cdf0e10cSrcweir 					break;
1743cdf0e10cSrcweir 				}
1744cdf0e10cSrcweir 				default:
1745cdf0e10cSrcweir 					OSL_ENSURE(0,"Not supported at the moment!");
1746cdf0e10cSrcweir 			}
1747cdf0e10cSrcweir 			nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
1748cdf0e10cSrcweir 		}
1749cdf0e10cSrcweir 		while (nRet == SQL_NEED_DATA);
1750cdf0e10cSrcweir 	}
1751cdf0e10cSrcweir }
1752cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_getColumnType_nothrow(sal_Int32 columnIndex)1753cdf0e10cSrcweir SWORD OResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
1754cdf0e10cSrcweir {
1755cdf0e10cSrcweir     ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
1756cdf0e10cSrcweir     if ( aFind == m_aODBCColumnTypes.end() )
1757cdf0e10cSrcweir         aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
1758cdf0e10cSrcweir     return aFind->second;
1759cdf0e10cSrcweir }
1760cdf0e10cSrcweir 
1761