merged tag ooo/DEV300_m102
[LibreOffice.git] / dbaccess / source / core / api / CacheSet.cxx
blob783c93f56593e967289c0e7f3dc422f694077ccd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
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
68 #include <limits>
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>
91 using namespace comphelper;
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;
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)
115 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::OCacheSet" );
116 DBG_CTOR(OCacheSet,NULL);
119 // -------------------------------------------------------------------------
120 ::rtl::OUString OCacheSet::getIdentifierQuoteString() const
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;
129 // -------------------------------------------------------------------------
130 void OCacheSet::construct( const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& /*i_sRowSetFilter*/)
132 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::construct" );
133 OSL_ENSURE(_xDriverSet.is(),"Invalid resultSet");
134 if(_xDriverSet.is())
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() )
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)
150 *pNullableIter = m_xSetMetaData->isNullable(i) != ColumnValue::NO_NULLS;
151 *pSignedIter = m_xSetMetaData->isSigned(i);
152 *pColumnIter = m_xSetMetaData->getColumnType(i);
155 Reference< XStatement> xStmt(m_xDriverSet->getStatement(),UNO_QUERY);
156 if(xStmt.is())
157 m_xConnection = xStmt->getConnection();
158 else
160 Reference< XPreparedStatement> xPrepStmt(m_xDriverSet->getStatement(),UNO_QUERY);
161 if ( xPrepStmt.is() )
162 m_xConnection = xPrepStmt->getConnection();
166 // -------------------------------------------------------------------------
167 OCacheSet::~OCacheSet()
171 m_xDriverSet = NULL;
172 m_xDriverRow = NULL;
173 m_xSetMetaData = NULL;
174 m_xConnection = NULL;
176 catch(Exception&)
178 OSL_ENSURE(0,"Exception occured");
180 catch(...)
182 OSL_ENSURE(0,"Unknown Exception occured");
185 DBG_DTOR(OCacheSet,NULL);
187 // -----------------------------------------------------------------------------
188 void OCacheSet::fillTableName(const Reference<XPropertySet>& _xTable) throw(SQLException, RuntimeException)
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() )
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);
203 // -------------------------------------------------------------------------
204 void SAL_CALL OCacheSet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
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);
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)
223 aSql.append(::dbtools::quoteName( aQuote,m_xSetMetaData->getColumnName(i++)));
224 aSql.append(aComma);
225 aValues.append(aPara);
228 aSql.setCharAt(aSql.getLength()-1,')');
229 aValues.setCharAt(aValues.getLength()-1,')');
231 aSql.append(aValues.makeStringAndClear());
232 // now create end execute the prepared statement
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)
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));
245 m_bInserted = xPrep->executeUpdate() > 0;
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 // }
263 // TODO set the bookmark in the insert row
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)
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);
283 // Reference<XColumnsSupplier>
284 Reference<XPropertySet> xIndexColsSup;
285 Reference<XNameAccess> xIndexColumns;
286 ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
287 if(xIndexes.is())
289 for(sal_Int32 j=0;j<xIndexes->getCount();++j)
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))
296 aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
300 ::rtl::OUString aColumnName;
302 static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii("?,");
303 static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
305 ::rtl::OUString aQuote = getIdentifierQuoteString();
307 sal_Int32 nCheckCount = 1; // index for the orginal values
308 sal_Int32 i = 1;
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)
316 aColumnName = m_xSetMetaData->getColumnName(i);
317 if(xPrimaryKeyColumns.is() && xPrimaryKeyColumns->hasByName(aColumnName))
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);
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)
332 if((*aIndexIter)->hasByName(aColumnName))
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;
344 if(aIter->isModified())
346 _sParameter.append(::dbtools::quoteName( aQuote,aColumnName));
347 _sParameter.append(aPara);
351 // -------------------------------------------------------------------------
352 void SAL_CALL OCacheSet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
354 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::updateRow" );
355 Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
356 fillTableName(xSet);
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
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() )
369 aCondition.setLength(aCondition.getLength()-5);
371 aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
372 aSql.append(aCondition.makeStringAndClear());
374 else
375 ::dbtools::throwSQLException(
376 DBACORE_RESSTRING( RID_STR_NO_UPDATE_MISSING_CONDITION ), SQL_GENERAL_ERROR, *this );
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)
385 if(aIter->isModified())
387 setParameter(i,xParameter,*aIter,m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
388 ++i;
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)
394 setParameter(i,xParameter,(_rOrginalRow->get())[*aOrgValue],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
397 m_bUpdated = xPrep->executeUpdate() > 0;
399 // -------------------------------------------------------------------------
400 void SAL_CALL OCacheSet::deleteRow(const ORowSetRow& _rDeleteRow ,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException)
402 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::deleteRow" );
403 Reference<XPropertySet> xSet(_xTable,UNO_QUERY);
404 fillTableName(xSet);
406 ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM ");
407 aSql.append(m_aComposedTableName);
408 aSql.append(::rtl::OUString::createFromAscii(" WHERE "));
410 // list all cloumns that should be set
411 ::rtl::OUString aQuote = getIdentifierQuoteString();
412 static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND ");
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);
423 // Reference<XColumnsSupplier>
424 Reference<XPropertySet> xIndexColsSup;
425 Reference<XNameAccess> xIndexColumns;
426 ::std::vector< Reference<XNameAccess> > aAllIndexColumns;
427 if(xIndexes.is())
429 for(sal_Int32 j=0;j<xIndexes->getCount();++j)
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))
436 aAllIndexColumns.push_back(Reference<XColumnsSupplier>(xIndexColsSup,UNO_QUERY)->getColumns());
440 ::rtl::OUStringBuffer aColumnName;
441 ::std::list< sal_Int32> aOrgValues;
442 fillParameters(_rDeleteRow,_xTable,aSql,aColumnName,aOrgValues);
444 aSql.setLength(aSql.getLength()-5);
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)
453 setParameter(i,xParameter,(_rDeleteRow->get())[*j],m_xSetMetaData->getColumnType(i),m_xSetMetaData->getScale(i));
456 m_bDeleted = xPrep->executeUpdate() > 0;
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
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);
469 // -------------------------------------------------------------------------
470 void OCacheSet::fillValueRow(ORowSetRow& _rRow,sal_Int32 _nPosition)
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);
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)
483 aIter->setSigned(m_aSignedFlags[i-1]);
484 aIter->fill(i,m_aColumnTypes[i-1],m_aNullable[i-1],this);
487 // -----------------------------------------------------------------------------
488 sal_Bool SAL_CALL OCacheSet::wasNull( ) throw(SQLException, RuntimeException)
490 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::wasNull" );
491 return m_xDriverRow->wasNull();
493 // -------------------------------------------------------------------------
494 ::rtl::OUString SAL_CALL OCacheSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
496 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getString" );
497 return m_xDriverRow->getString(columnIndex);
499 // -------------------------------------------------------------------------
500 sal_Bool SAL_CALL OCacheSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
502 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBoolean" );
503 return m_xDriverRow->getBoolean(columnIndex);
505 // -------------------------------------------------------------------------
506 sal_Int8 SAL_CALL OCacheSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
508 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getByte" );
509 return m_xDriverRow->getByte(columnIndex);
511 // -------------------------------------------------------------------------
512 sal_Int16 SAL_CALL OCacheSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
514 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getShort" );
515 return m_xDriverRow->getShort(columnIndex);
517 // -------------------------------------------------------------------------
518 sal_Int32 SAL_CALL OCacheSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
520 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getInt" );
521 return m_xDriverRow->getInt(columnIndex);
523 // -------------------------------------------------------------------------
524 sal_Int64 SAL_CALL OCacheSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
526 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getLong" );
527 return m_xDriverRow->getLong(columnIndex);
529 // -------------------------------------------------------------------------
530 float SAL_CALL OCacheSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
532 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getFloat" );
533 return m_xDriverRow->getFloat(columnIndex);
535 // -------------------------------------------------------------------------
536 double SAL_CALL OCacheSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
538 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDouble" );
539 return m_xDriverRow->getDouble(columnIndex);
541 // -------------------------------------------------------------------------
542 Sequence< sal_Int8 > SAL_CALL OCacheSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
544 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBytes" );
545 return m_xDriverRow->getBytes(columnIndex);
547 // -------------------------------------------------------------------------
548 ::com::sun::star::util::Date SAL_CALL OCacheSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
550 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getDate" );
551 return m_xDriverRow->getDate(columnIndex);
553 // -------------------------------------------------------------------------
554 ::com::sun::star::util::Time SAL_CALL OCacheSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
556 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTime" );
557 return m_xDriverRow->getTime(columnIndex);
559 // -------------------------------------------------------------------------
560 ::com::sun::star::util::DateTime SAL_CALL OCacheSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
562 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getTimestamp" );
563 return m_xDriverRow->getTimestamp(columnIndex);
565 // -------------------------------------------------------------------------
566 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
568 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBinaryStream" );
569 return m_xDriverRow->getBinaryStream(columnIndex);
571 // -------------------------------------------------------------------------
572 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCacheSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
574 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getCharacterStream" );
575 return m_xDriverRow->getCharacterStream(columnIndex);
577 // -------------------------------------------------------------------------
578 Any SAL_CALL OCacheSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
580 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getObject" );
581 return m_xDriverRow->getObject(columnIndex,typeMap);
583 // -------------------------------------------------------------------------
584 Reference< XRef > SAL_CALL OCacheSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
586 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRef" );
587 return m_xDriverRow->getRef(columnIndex);
589 // -------------------------------------------------------------------------
590 Reference< XBlob > SAL_CALL OCacheSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
592 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getBlob" );
593 return m_xDriverRow->getBlob(columnIndex);
595 // -------------------------------------------------------------------------
596 Reference< XClob > SAL_CALL OCacheSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
598 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getClob" );
599 return m_xDriverRow->getClob(columnIndex);
601 // -------------------------------------------------------------------------
602 Reference< XArray > SAL_CALL OCacheSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
604 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getArray" );
605 return m_xDriverRow->getArray(columnIndex);
607 // -------------------------------------------------------------------------
608 // XResultSet
609 sal_Bool SAL_CALL OCacheSet::next( ) throw(SQLException, RuntimeException)
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();
615 // -------------------------------------------------------------------------
616 sal_Bool SAL_CALL OCacheSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
618 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isBeforeFirst" );
619 return m_xDriverSet->isBeforeFirst();
621 // -------------------------------------------------------------------------
622 sal_Bool SAL_CALL OCacheSet::isAfterLast( ) throw(SQLException, RuntimeException)
624 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isAfterLast" );
625 return m_xDriverSet->isAfterLast();
627 // -------------------------------------------------------------------------
628 sal_Bool SAL_CALL OCacheSet::isFirst( ) throw(SQLException, RuntimeException)
630 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isFirst" );
631 return m_xDriverSet->isFirst();
633 // -------------------------------------------------------------------------
634 sal_Bool SAL_CALL OCacheSet::isLast( ) throw(SQLException, RuntimeException)
636 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::isLast" );
637 return m_xDriverSet->isLast();
639 // -------------------------------------------------------------------------
640 void SAL_CALL OCacheSet::beforeFirst( ) throw(SQLException, RuntimeException)
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();
646 // -------------------------------------------------------------------------
647 void SAL_CALL OCacheSet::afterLast( ) throw(SQLException, RuntimeException)
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();
653 // -------------------------------------------------------------------------
654 sal_Bool SAL_CALL OCacheSet::first( ) throw(SQLException, RuntimeException)
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();
660 // -------------------------------------------------------------------------
661 sal_Bool SAL_CALL OCacheSet::last( ) throw(SQLException, RuntimeException)
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();
667 // -------------------------------------------------------------------------
668 sal_Int32 SAL_CALL OCacheSet::getRow( ) throw(SQLException, RuntimeException)
670 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getRow" );
671 return m_xDriverSet->getRow();
673 // -------------------------------------------------------------------------
674 sal_Bool SAL_CALL OCacheSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
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);
680 // -------------------------------------------------------------------------
681 sal_Bool SAL_CALL OCacheSet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException)
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);
687 // -------------------------------------------------------------------------
688 sal_Bool SAL_CALL OCacheSet::previous( ) throw(SQLException, RuntimeException)
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();
694 // -------------------------------------------------------------------------
695 void SAL_CALL OCacheSet::refreshRow( ) throw(SQLException, RuntimeException)
697 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::refreshRow" );
698 m_xDriverSet->refreshRow();
700 // -------------------------------------------------------------------------
701 sal_Bool SAL_CALL OCacheSet::rowUpdated( ) throw(SQLException, RuntimeException)
703 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowUpdated" );
704 return m_xDriverSet->rowUpdated();
706 // -------------------------------------------------------------------------
707 sal_Bool SAL_CALL OCacheSet::rowInserted( ) throw(SQLException, RuntimeException)
709 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowInserted" );
710 return m_xDriverSet->rowInserted();
712 // -------------------------------------------------------------------------
713 sal_Bool SAL_CALL OCacheSet::rowDeleted( ) throw(SQLException, RuntimeException)
715 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::rowDeleted" );
716 return m_xDriverSet->rowDeleted();
718 // -------------------------------------------------------------------------
719 Reference< XInterface > SAL_CALL OCacheSet::getStatement( ) throw(SQLException, RuntimeException)
721 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCacheSet::getStatement" );
722 return m_xDriverSet->getStatement();
724 // -----------------------------------------------------------------------------
725 bool OCacheSet::isResultSetChanged() const
727 return false;
729 // -----------------------------------------------------------------------------
730 void OCacheSet::reset(const Reference< XResultSet>& /*_xDriverSet*/)
732 OSL_ENSURE(0,"Illegal call!");
734 // -----------------------------------------------------------------------------
735 void OCacheSet::mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& /*io_aInsertRow*/,ORowSetValueVector::Vector& /*io_aRow*/,::std::vector<sal_Int32>& o_aChangedColumns)
737 o_aChangedColumns.push_back(i_nColumnIndex);
739 // -----------------------------------------------------------------------------
740 bool OCacheSet::columnValuesUpdated(ORowSetValueVector::Vector& /*io_aCachedRow*/,const ORowSetValueVector::Vector& /*io_aRow*/)
742 return false;
744 // -----------------------------------------------------------------------------
745 bool OCacheSet::updateColumnValues(const ORowSetValueVector::Vector& /*io_aCachedRow*/,ORowSetValueVector::Vector& /*io_aRow*/,const ::std::vector<sal_Int32>& /*i_aChangedColumns*/)
747 return true;
749 // -----------------------------------------------------------------------------
750 void OCacheSet::fillMissingValues(ORowSetValueVector::Vector& /*io_aRow*/) const
753 // -----------------------------------------------------------------------------