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