xref: /trunk/main/dbaccess/source/core/api/CacheSet.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dbaccess.hxx"
30 #ifndef DBACCESS_CORE_API_CACHESET_HXX
31 #include "CacheSet.hxx"
32 #endif
33 #ifndef _DBA_CORE_RESOURCE_HXX_
34 #include "core_resource.hxx"
35 #endif
36 #ifndef _DBA_CORE_RESOURCE_HRC_
37 #include "core_resource.hrc"
38 #endif
39 #ifndef _COM_SUN_STAR_SDBCX_COMPAREBOOKMARK_HPP_
40 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
43 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
49 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
52 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
53 #endif
54 #include <com/sun/star/sdbc/ColumnValue.hpp>
55 #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
56 #include <com/sun/star/sdbc/XParameters.hpp>
57 #endif
58 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
59 #include "dbastrings.hrc"
60 #endif
61 #ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
62 #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
63 #endif
64 #ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_
65 #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
66 #endif
67 
68 #include <limits>
69 
70 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
71 #include <connectivity/dbtools.hxx>
72 #endif
73 #ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
74 #include <com/sun/star/sdbcx/KeyType.hpp>
75 #endif
76 #ifndef _COMPHELPER_EXTRACT_HXX_
77 #include <comphelper/extract.hxx>
78 #endif
79 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
80 #include <com/sun/star/io/XInputStream.hpp>
81 #endif
82 #ifndef _COMPHELPER_TYPES_HXX_
83 #include <comphelper/types.hxx>
84 #endif
85 #ifndef _TOOLS_DEBUG_HXX
86 #include <tools/debug.hxx>
87 #endif
88 #include <rtl/ustrbuf.hxx>
89 #include <rtl/logfile.hxx>
90 
91 using namespace comphelper;
92 
93 using namespace dbaccess;
94 using namespace dbtools;
95 using namespace connectivity;
96 using namespace ::com::sun::star::uno;
97 using namespace ::com::sun::star::beans;
98 using namespace ::com::sun::star::sdbc;
99 //	using namespace ::com::sun::star::sdb;
100 using namespace ::com::sun::star::sdbcx;
101 using namespace ::com::sun::star::container;
102 using namespace ::com::sun::star::lang;
103 using namespace ::com::sun::star::io;
104 //	using namespace ::cppu;
105 using namespace ::osl;
106 
107 DBG_NAME(OCacheSet)
108 // -------------------------------------------------------------------------
109 OCacheSet::OCacheSet(sal_Int32 i_nMaxRows)
110 			:m_nMaxRows(i_nMaxRows)
111             ,m_bInserted(sal_False)
112 			,m_bUpdated(sal_False)
113 			,m_bDeleted(sal_False)
114 {
115     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::OCacheSet" );
116     DBG_CTOR(OCacheSet,NULL);
117 
118 }
119 // -------------------------------------------------------------------------
120 ::rtl::OUString OCacheSet::getIdentifierQuoteString() const
121 {
122     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getIdentifierQuoteString" );
123 	::rtl::OUString sQuote;
124 	Reference<XDatabaseMetaData> xMeta;
125 	if ( m_xConnection.is() && (xMeta = m_xConnection->getMetaData()).is() )
126 		sQuote = xMeta->getIdentifierQuoteString();
127 	return sQuote;
128 }
129 // -------------------------------------------------------------------------
130 void OCacheSet::construct(	const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/)
131 {
132     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" );
133 	OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet");
134 	if(_xDriverSet.is())
135 	{
136 		m_xDriverSet = _xDriverSet;
137 		m_xDriverRow.set(_xDriverSet,UNO_QUERY);
138 		m_xSetMetaData = Reference<XResultSetMetaDataSupplier>(_xDriverSet,UNO_QUERY)->getMetaData();
139 		if ( m_xSetMetaData.is() )
140 		{
141 			const sal_Int32 nCount = m_xSetMetaData->getColumnCount();
142             m_aNullable.realloc(nCount);
143 			m_aSignedFlags.realloc(nCount);
144             m_aColumnTypes.realloc(nCount);
145             sal_Bool* pNullableIter = m_aNullable.getArray();
146 			sal_Bool* pSignedIter = m_aSignedFlags.getArray();
147             sal_Int32* pColumnIter = m_aColumnTypes.getArray();
148 			for (sal_Int32 i=1; i <= nCount; ++i,++pSignedIter,++pColumnIter,++pNullableIter)
149 			{
150                 *pNullableIter = m_xSetMetaData->isNullable(i) != ColumnValue::NO_NULLS;
151 				*pSignedIter = m_xSetMetaData->isSigned(i);
152                 *pColumnIter = m_xSetMetaData->getColumnType(i);
153 			}
154 		}
155 		Reference< XStatement> xStmt(m_xDriverSet->getStatement(),UNO_QUERY);
156 		if(xStmt.is())
157 			m_xConnection = xStmt->getConnection();
158 		else
159 		{
160 			Reference< XPreparedStatement> xPrepStmt(m_xDriverSet->getStatement(),UNO_QUERY);
161 			if ( xPrepStmt.is() )
162 				m_xConnection = xPrepStmt->getConnection();
163 		}
164 	}
165 }
166 // -------------------------------------------------------------------------
167 OCacheSet::~OCacheSet()
168 {
169 	try
170 	{
171 		m_xDriverSet = NULL;
172 		m_xDriverRow = NULL;
173 		m_xSetMetaData = NULL;
174 		m_xConnection = NULL;
175 	}
176 	catch(Exception&)
177 	{
178 		OSL_ENSURE(0,"Exception occured");
179 	}
180 	catch(...)
181 	{
182 		OSL_ENSURE(0,"Unknown Exception occured");
183 	}
184 
185     DBG_DTOR(OCacheSet,NULL);
186 }
187 // -----------------------------------------------------------------------------
188 void OCacheSet::fillTableName(const Reference<XPropertySet>& _xTable)  throw(SQLException, RuntimeException)
189 {
190     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillTableName" );
191 	OSL_ENSURE(_xTable.is(),"OCacheSet::fillTableName: PropertySet is empty!");
192 	if(!m_aComposedTableName.getLength() && _xTable.is() )
193 	{
194 		Reference<XDatabaseMetaData> xMeta(m_xConnection->getMetaData());
195 		m_aComposedTableName = composeTableName(xMeta
196 						,comphelper::getString(_xTable->getPropertyValue(PROPERTY_CATALOGNAME))
197 						,comphelper::getString(_xTable->getPropertyValue(PROPERTY_SCHEMANAME))
198 						,comphelper::getString(_xTable->getPropertyValue(PROPERTY_NAME))
199 						,sal_True
200 						,::dbtools::eInDataManipulation);
201 	}
202 }
203 // -------------------------------------------------------------------------
204 void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
205 {
206     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::insertRow" );
207 	::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO ")));
208 	Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
209 	fillTableName(xSet);
210 
211 	aSql.append(m_aComposedTableName);
212 	aSql.append(::rtl::OUString::createFromAscii(" ( "));
213 	// set values and column names
214 	::rtl::OUStringBuffer aValues = ::rtl::OUString::createFromAscii(" VALUES ( ");
215     static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,"));
216 	::rtl::OUString aQuote = getIdentifierQuoteString();
217 	static ::rtl::OUString aComma(RTL_CONSTASCII_USTRINGPARAM(","));
218 	sal_Int32 i = 1;
219 	ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1;
220     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
221 	for(; aIter != aEnd;++aIter)
222 	{
223 		aSql.append(::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++)));
224 		aSql.append(aComma);
225 		aValues.append(aPara);
226 	}
227 
228     aSql.setCharAt(aSql.getLength()-1,')');
229     aValues.setCharAt(aValues.getLength()-1,')');
230 
231 	aSql.append(aValues.makeStringAndClear());
232 	// now create end execute the prepared statement
233 	{
234 		Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
235 		Reference< XParameters > xParameter(xPrep,UNO_QUERY);
236 		i = 1;
237 		for(aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter,++i)
238 		{
239 			if(aIter->isNull())
240 				xParameter->setNull(i,aIter->getTypeKind());
241 			else
242 				setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
243 		}
244 
245 		m_bInserted = xPrep->executeUpdate() > 0;
246 	}
247 
248 //	::rtl::OUString aCountSql = ::rtl::OUString::createFromAscii("SELECT COUNT(*) FROM ");
249 //	aCountSql += m_aComposedTableName;
250 //	try
251 //	{
252 //		Reference< XStatement > xStmt(m_xConnection->createStatement());
253 //		Reference<XResultSet> xRes(xStmt->executeQuery(aCountSql));
254 //		if(xRes.is() && xRes->next())
255 //		{
256 //			Reference<XRow> xRow(xRes,UNO_QUERY);
257 //		}
258 //	}
259 //	catch(SQLException&)
260 //	{
261 //	}
262 
263 	// TODO set the bookmark in the insert row
264 }
265 // -------------------------------------------------------------------------
266 void OCacheSet::fillParameters( const ORowSetRow& _rRow
267 										,const connectivity::OSQLTable& _xTable
268 										,::rtl::OUStringBuffer& _sCondition
269 										,::rtl::OUStringBuffer& _sParameter
270 										,::std::list< sal_Int32>& _rOrgValues)
271 {
272     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillParameters" );
273 	// use keys and indexes for excat postioning
274 	// first the keys
275     Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
276     const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
277 	// second the indexes
278 	Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
279 	Reference<XIndexAccess> xIndexes;
280 	if(xIndexSup.is())
281 		xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
282 
283 	//	Reference<XColumnsSupplier>
284 	Reference<XPropertySet> xIndexColsSup;
285 	Reference<XNameAccess> xIndexColumns;
286 	::std::vector< Reference<XNameAccess> > aAllIndexColumns;
287 	if(xIndexes.is())
288 	{
289 		for(sal_Int32 j=0;j<xIndexes->getCount();++j)
290 		{
291 			xIndexColsSup.set(xIndexes->getByIndex(j),UNO_QUERY);
292 			if(	xIndexColsSup.is()
293 				&& comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
294 				&& !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
295 			  )
296 				aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
297 		}
298 	}
299 
300 	::rtl::OUString aColumnName;
301 
302 	static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii("?,");
303 	static ::rtl::OUString aAnd		= ::rtl::OUString::createFromAscii(" AND ");
304 
305 	::rtl::OUString aQuote	= getIdentifierQuoteString();
306 
307 	sal_Int32 nCheckCount = 1; // index for the orginal values
308 	sal_Int32 i = 1;
309 
310     ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"));
311     ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?"));
312 	ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rRow->get().begin()+1;
313 	ORowVector< ORowSetValue >::Vector::const_iterator aEnd = _rRow->get().end()+1;
314 	for(; aIter != aEnd;++aIter,++nCheckCount,++i)
315 	{
316 		aColumnName = m_xSetMetaData->getColumnName(i);
317 		if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName))
318 		{
319             _sCondition.append(::dbtools::quoteName( aQuote,aColumnName));
320 			if(aIter->isNull())
321 				_sCondition.append(sIsNull);
322 			else
323 				_sCondition.append(sParam);
324 			_sCondition.append(aAnd);
325 			_rOrgValues.push_back(nCheckCount);
326 
327 		} // if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName))
328         ::std::vector< Reference<XNameAccess> >::const_iterator aIndexEnd = aAllIndexColumns.end();
329 		for( ::std::vector< Reference<XNameAccess> >::const_iterator aIndexIter = aAllIndexColumns.begin();
330 				aIndexIter != aIndexEnd;++aIndexIter)
331 		{
332 			if((*aIndexIter)->hasByName(aColumnName))
333 			{
334 				_sCondition.append(::dbtools::quoteName( aQuote,aColumnName));
335 				if(aIter->isNull())
336 					_sCondition.append(sIsNull);
337 				else
338 					_sCondition.append(sParam);
339 				_sCondition.append(aAnd);
340 				_rOrgValues.push_back(nCheckCount);
341 				break;
342 			}
343 		}
344 		if(aIter->isModified())
345 		{
346             _sParameter.append(::dbtools::quoteName( aQuote,aColumnName));
347 			_sParameter.append(aPara);
348 		}
349 	}
350 }
351 // -------------------------------------------------------------------------
352 void SAL_CALL OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable  ) throw(SQLException, RuntimeException)
353 {
354     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::updateRow" );
355 	Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
356 	fillTableName(xSet);
357 
358 	::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE ");
359     aSql.append(m_aComposedTableName);
360 	aSql.append(::rtl::OUString::createFromAscii(" SET "));
361 	// list all cloumns that should be set
362 
363 	::rtl::OUStringBuffer aCondition;
364 	::std::list< sal_Int32> aOrgValues;
365 	fillParameters(_rInsertRow,_xTable,aCondition,aSql,aOrgValues);
366     aSql.setCharAt(aSql.getLength()-1,' ');
367 	if ( aCondition.getLength() )
368 	{
369 		aCondition.setLength(aCondition.getLength()-5);
370 
371 		aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
372         aSql.append(aCondition.makeStringAndClear());
373 	}
374 	else
375         ::dbtools::throwSQLException(
376             DBACORE_RESSTRING( RID_STR_NO_UPDATE_MISSING_CONDITION ), SQL_GENERAL_ERROR, *this );
377 
378 	// now create end execute the prepared statement
379     Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
380 	Reference< XParameters > xParameter(xPrep,UNO_QUERY);
381 	sal_Int32 i = 1;
382     connectivity::ORowVector< ORowSetValue > ::Vector::iterator aEnd = _rInsertRow->get().end();
383 	for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter)
384 	{
385 		if(aIter->isModified())
386 		{
387 			setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
388 			++i;
389 		}
390 	} // for(ORowVector< ORowSetValue >::Vector::const_iterator aIter = _rInsertRow->get().begin()+1; aIter != aEnd;++aIter)
391     ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end();
392 	for(::std::list< sal_Int32>::const_iterator aOrgValue = aOrgValues.begin(); aOrgValue != aOrgValueEnd;++aOrgValue,++i)
393 	{
394 		setParameter(i,xParameter,(_rOrginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
395 	}
396 
397  	m_bUpdated = xPrep->executeUpdate() > 0;
398 }
399 // -------------------------------------------------------------------------
400 void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQLTable& _xTable  ) throw(SQLException, RuntimeException)
401 {
402     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::deleteRow" );
403 	Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
404 	fillTableName(xSet);
405 
406 	::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM ");
407 	aSql.append(m_aComposedTableName);
408 	aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
409 
410 	// list all cloumns that should be set
411 	::rtl::OUString aQuote	= getIdentifierQuoteString();
412 	static ::rtl::OUString aAnd		= ::rtl::OUString::createFromAscii(" AND ");
413 
414 	// use keys and indexes for excat postioning
415 	// first the keys
416     const Reference<XNameAccess> xPrimaryKeyColumns = getPrimaryKeyColumns_throw(xSet);
417 	// second the indexes
418 	Reference<XIndexesSupplier> xIndexSup(_xTable,UNO_QUERY);
419 	Reference<XIndexAccess> xIndexes;
420 	if(xIndexSup.is())
421 		xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
422 
423 	//	Reference<XColumnsSupplier>
424 	Reference<XPropertySet> xIndexColsSup;
425 	Reference<XNameAccess> xIndexColumns;
426 	::std::vector< Reference<XNameAccess> > aAllIndexColumns;
427 	if(xIndexes.is())
428 	{
429 		for(sal_Int32 j=0;j<xIndexes->getCount();++j)
430 		{
431             xIndexColsSup.set(xIndexes->getByIndex(j),UNO_QUERY);
432 			if(	xIndexColsSup.is()
433 				&& comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISUNIQUE))
434 				&& !comphelper::getBOOL(xIndexColsSup->getPropertyValue(PROPERTY_ISPRIMARYKEYINDEX))
435 			  )
436 				aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
437 		}
438 	}
439 
440 	::rtl::OUStringBuffer aColumnName;
441 	::std::list< sal_Int32> aOrgValues;
442 	fillParameters(_rDeleteRow,_xTable,aSql,aColumnName,aOrgValues);
443 
444     aSql.setLength(aSql.getLength()-5);
445 
446 	// now create end execute the prepared statement
447     Reference< XPreparedStatement > xPrep(m_xConnection->prepareStatement(aSql.makeStringAndClear()));
448 	Reference< XParameters > xParameter(xPrep,UNO_QUERY);
449 	sal_Int32 i = 1;
450     ::std::list< sal_Int32>::const_iterator aOrgValueEnd = aOrgValues.end();
451 	for(::std::list< sal_Int32>::const_iterator j = aOrgValues.begin(); j != aOrgValueEnd;++j,++i)
452 	{
453 		setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
454 	}
455 
456 	m_bDeleted = xPrep->executeUpdate() > 0;
457 }
458 // -------------------------------------------------------------------------
459 void OCacheSet::setParameter(sal_Int32 nPos
460 							 ,const Reference< XParameters >& _xParameter
461 							 ,const ORowSetValue& _rValue
462 							 ,sal_Int32 _nType
463                              ,sal_Int32 _nScale) const
464 {
465     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::setParameter" );
466 	sal_Int32 nType = ( _nType != DataType::OTHER ) ? _nType : _rValue.getTypeKind();
467 	::dbtools::setObjectWithInfo(_xParameter,nPos,_rValue,nType,_nScale);
468 }
469 // -------------------------------------------------------------------------
470 void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
471 {
472     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::fillValueRow" );
473 	Any aBookmark = getBookmark();
474 	if(!aBookmark.hasValue())
475 		aBookmark = makeAny(_nPosition);
476 
477     connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rRow->get().begin();
478     connectivity::ORowVector< ORowSetValue >::Vector::iterator aEnd = _rRow->get().end();
479 	(*aIter) = aBookmark;
480 	++aIter;
481 	for(sal_Int32 i=1;aIter != aEnd;++aIter,++i)
482 	{
483 		aIter->setSigned(m_aSignedFlags[i-1]);
484         aIter->fill(i,m_aColumnTypes[i-1],m_aNullable[i-1],this);
485 	}
486 }
487 // -----------------------------------------------------------------------------
488 sal_Bool SAL_CALL OCacheSet::wasNull(  ) throw(SQLException, RuntimeException)
489 {
490     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::wasNull" );
491 	return m_xDriverRow->wasNull();
492 }
493 // -------------------------------------------------------------------------
494 ::rtl::OUString SAL_CALL OCacheSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
495 {
496     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getString" );
497 	return m_xDriverRow->getString(columnIndex);
498 }
499 // -------------------------------------------------------------------------
500 sal_Bool SAL_CALL OCacheSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
501 {
502     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBoolean" );
503 	return m_xDriverRow->getBoolean(columnIndex);
504 }
505 // -------------------------------------------------------------------------
506 sal_Int8 SAL_CALL OCacheSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
507 {
508     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getByte" );
509 	return m_xDriverRow->getByte(columnIndex);
510 }
511 // -------------------------------------------------------------------------
512 sal_Int16 SAL_CALL OCacheSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
513 {
514     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getShort" );
515 	return m_xDriverRow->getShort(columnIndex);
516 }
517 // -------------------------------------------------------------------------
518 sal_Int32 SAL_CALL OCacheSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
519 {
520     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getInt" );
521 	return m_xDriverRow->getInt(columnIndex);
522 }
523 // -------------------------------------------------------------------------
524 sal_Int64 SAL_CALL OCacheSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
525 {
526     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getLong" );
527 	return m_xDriverRow->getLong(columnIndex);
528 }
529 // -------------------------------------------------------------------------
530 float SAL_CALL OCacheSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
531 {
532     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getFloat" );
533 	return m_xDriverRow->getFloat(columnIndex);
534 }
535 // -------------------------------------------------------------------------
536 double SAL_CALL OCacheSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
537 {
538     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDouble" );
539 	return m_xDriverRow->getDouble(columnIndex);
540 }
541 // -------------------------------------------------------------------------
542 Sequence< sal_Int8 > SAL_CALL OCacheSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
543 {
544     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBytes" );
545 	return m_xDriverRow->getBytes(columnIndex);
546 }
547 // -------------------------------------------------------------------------
548 ::com::sun::star::util::Date SAL_CALL OCacheSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
549 {
550     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDate" );
551 	return m_xDriverRow->getDate(columnIndex);
552 }
553 // -------------------------------------------------------------------------
554 ::com::sun::star::util::Time SAL_CALL OCacheSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
555 {
556     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTime" );
557 	return m_xDriverRow->getTime(columnIndex);
558 }
559 // -------------------------------------------------------------------------
560 ::com::sun::star::util::DateTime SAL_CALL OCacheSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
561 {
562     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTimestamp" );
563 	return m_xDriverRow->getTimestamp(columnIndex);
564 }
565 // -------------------------------------------------------------------------
566 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
567 {
568     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBinaryStream" );
569 	return m_xDriverRow->getBinaryStream(columnIndex);
570 }
571 // -------------------------------------------------------------------------
572 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
573 {
574     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getCharacterStream" );
575 	return m_xDriverRow->getCharacterStream(columnIndex);
576 }
577 // -------------------------------------------------------------------------
578 Any SAL_CALL OCacheSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
579 {
580     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getObject" );
581 	return m_xDriverRow->getObject(columnIndex,typeMap);
582 }
583 // -------------------------------------------------------------------------
584 Reference< XRef > SAL_CALL OCacheSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
585 {
586     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRef" );
587 	return m_xDriverRow->getRef(columnIndex);
588 }
589 // -------------------------------------------------------------------------
590 Reference< XBlob > SAL_CALL OCacheSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
591 {
592     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBlob" );
593 	return m_xDriverRow->getBlob(columnIndex);
594 }
595 // -------------------------------------------------------------------------
596 Reference< XClob > SAL_CALL OCacheSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
597 {
598     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getClob" );
599 	return m_xDriverRow->getClob(columnIndex);
600 }
601 // -------------------------------------------------------------------------
602 Reference< XArray > SAL_CALL OCacheSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
603 {
604     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getArray" );
605 	return m_xDriverRow->getArray(columnIndex);
606 }
607 // -------------------------------------------------------------------------
608 // XResultSet
609 sal_Bool SAL_CALL OCacheSet::next(  ) throw(SQLException, RuntimeException)
610 {
611     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::next" );
612 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
613 	return m_xDriverSet->next();
614 }
615 // -------------------------------------------------------------------------
616 sal_Bool SAL_CALL OCacheSet::isBeforeFirst(  ) throw(SQLException, RuntimeException)
617 {
618     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isBeforeFirst" );
619 	return m_xDriverSet->isBeforeFirst();
620 }
621 // -------------------------------------------------------------------------
622 sal_Bool SAL_CALL OCacheSet::isAfterLast(  ) throw(SQLException, RuntimeException)
623 {
624     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isAfterLast" );
625 	return m_xDriverSet->isAfterLast();
626 }
627 // -------------------------------------------------------------------------
628 sal_Bool SAL_CALL OCacheSet::isFirst(  ) throw(SQLException, RuntimeException)
629 {
630     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isFirst" );
631 	return m_xDriverSet->isFirst();
632 }
633 // -------------------------------------------------------------------------
634 sal_Bool SAL_CALL OCacheSet::isLast(  ) throw(SQLException, RuntimeException)
635 {
636     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isLast" );
637 	return m_xDriverSet->isLast();
638 }
639 // -------------------------------------------------------------------------
640 void SAL_CALL OCacheSet::beforeFirst(  ) throw(SQLException, RuntimeException)
641 {
642     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::beforeFirst" );
643 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
644 	m_xDriverSet->beforeFirst();
645 }
646 // -------------------------------------------------------------------------
647 void SAL_CALL OCacheSet::afterLast(  ) throw(SQLException, RuntimeException)
648 {
649     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::afterLast" );
650 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
651 	m_xDriverSet->afterLast();
652 }
653 // -------------------------------------------------------------------------
654 sal_Bool SAL_CALL OCacheSet::first(  ) throw(SQLException, RuntimeException)
655 {
656     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::first" );
657 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
658 	return m_xDriverSet->first();
659 }
660 // -------------------------------------------------------------------------
661 sal_Bool SAL_CALL OCacheSet::last(  ) throw(SQLException, RuntimeException)
662 {
663     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::last" );
664 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
665 	return m_xDriverSet->last();
666 }
667 // -------------------------------------------------------------------------
668 sal_Int32 SAL_CALL OCacheSet::getRow(  ) throw(SQLException, RuntimeException)
669 {
670     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRow" );
671 	return m_xDriverSet->getRow();
672 }
673 // -------------------------------------------------------------------------
674 sal_Bool SAL_CALL OCacheSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
675 {
676     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::absolute" );
677 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
678 	return m_xDriverSet->absolute(row);
679 }
680 // -------------------------------------------------------------------------
681 sal_Bool SAL_CALL OCacheSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
682 {
683     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::relative" );
684 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
685 	return m_xDriverSet->relative(rows);
686 }
687 // -------------------------------------------------------------------------
688 sal_Bool SAL_CALL OCacheSet::previous(  ) throw(SQLException, RuntimeException)
689 {
690     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::previous" );
691 	m_bInserted = m_bUpdated = m_bDeleted = sal_False;
692 	return m_xDriverSet->previous();
693 }
694 sal_Bool OCacheSet::last_checked( sal_Bool /*i_bFetchRow*/)
695 {
696     return last();
697 }
698 // -------------------------------------------------------------------------
699 sal_Bool OCacheSet::previous_checked( sal_Bool /*i_bFetchRow*/ )
700 {
701     return previous();
702 }
703 // -------------------------------------------------------------------------
704 sal_Bool OCacheSet::absolute_checked( sal_Int32 row,sal_Bool /*i_bFetchRow*/ )
705 {
706     return absolute(row);
707 }
708 // -------------------------------------------------------------------------
709 void SAL_CALL OCacheSet::refreshRow(  ) throw(SQLException, RuntimeException)
710 {
711     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::refreshRow" );
712 	m_xDriverSet->refreshRow();
713 }
714 // -------------------------------------------------------------------------
715 sal_Bool SAL_CALL OCacheSet::rowUpdated(  ) throw(SQLException, RuntimeException)
716 {
717     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowUpdated" );
718 	return m_xDriverSet->rowUpdated();
719 }
720 // -------------------------------------------------------------------------
721 sal_Bool SAL_CALL OCacheSet::rowInserted(  ) throw(SQLException, RuntimeException)
722 {
723     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowInserted" );
724 	return m_xDriverSet->rowInserted();
725 }
726 // -------------------------------------------------------------------------
727 sal_Bool SAL_CALL OCacheSet::rowDeleted(  ) throw(SQLException, RuntimeException)
728 {
729     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowDeleted" );
730 	return m_xDriverSet->rowDeleted();
731 }
732 // -------------------------------------------------------------------------
733 Reference< XInterface > SAL_CALL OCacheSet::getStatement(  ) throw(SQLException, RuntimeException)
734 {
735     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getStatement" );
736 	return m_xDriverSet->getStatement();
737 }
738 // -----------------------------------------------------------------------------
739 bool OCacheSet::isResultSetChanged() const
740 {
741     return false;
742 }
743 // -----------------------------------------------------------------------------
744 void OCacheSet::reset(const Reference< XResultSet>& /*_xDriverSet*/)
745 {
746     OSL_ENSURE(0,"Illegal call!");
747 }
748 // -----------------------------------------------------------------------------
749 void OCacheSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& /*io_aInsertRow*/,ORowSetValueVector::Vector& /*io_aRow*/,::std::vector<sal_Int32>& o_aChangedColumns)
750 {
751     o_aChangedColumns.push_back(i_nColumnIndex);
752 }
753 // -----------------------------------------------------------------------------
754 bool OCacheSet::columnValuesUpdated(ORowSetValueVector::Vector& /*io_aCachedRow*/,const ORowSetValueVector::Vector& /*io_aRow*/)
755 {
756     return false;
757 }
758 // -----------------------------------------------------------------------------
759 bool OCacheSet::updateColumnValues(const ORowSetValueVector::Vector& /*io_aCachedRow*/,ORowSetValueVector::Vector& /*io_aRow*/,const ::std::vector<sal_Int32>& /*i_aChangedColumns*/)
760 {
761     return true;
762 }
763 // -----------------------------------------------------------------------------
764 void OCacheSet::fillMissingValues(ORowSetValueVector::Vector& /*io_aRow*/) const
765 {
766 }
767 // -----------------------------------------------------------------------------
768 
769