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