Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / core / api / resultset.cxx
blob46f5a5c2fefe288c3b4d514dc1734a65fda0693b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <resultset.hxx>
21 #include "dbastrings.hrc"
22 #include "apitools.hxx"
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <com/sun/star/sdbc/ResultSetType.hpp>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <cppuhelper/queryinterface.hxx>
27 #include <cppuhelper/typeprovider.hxx>
28 #include <comphelper/property.hxx>
29 #include <comphelper/sequence.hxx>
30 #include <comphelper/types.hxx>
31 #include <tools/debug.hxx>
32 #include <tools/diagnose_ex.h>
33 #include <datacolumn.hxx>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <connectivity/dbexception.hxx>
36 #include <connectivity/dbtools.hxx>
37 #include <cppuhelper/exc_hlp.hxx>
38 #include <osl/thread.h>
41 using namespace ::com::sun::star::sdbc;
42 using namespace ::com::sun::star::sdbcx;
43 using namespace ::com::sun::star::beans;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::container;
47 using namespace ::cppu;
48 using namespace ::osl;
49 using namespace dbaccess;
50 using namespace dbtools;
53 OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
54 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
55 bool _bCaseSensitive)
56 :OResultSetBase(m_aMutex)
57 ,OPropertySetHelper(OResultSetBase::rBHelper)
58 ,m_xDelegatorResultSet(_xResultSet)
59 ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
60 ,m_nResultSetType(0)
61 ,m_nResultSetConcurrency(0)
62 ,m_bIsBookmarkable(false)
64 m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< OUString>(), NULL,NULL);
66 try
68 m_aStatement = _xStatement;
69 m_xDelegatorResultSetUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
70 m_xDelegatorRow.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
71 m_xDelegatorRowUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
73 Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
74 xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
75 xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
77 // test for Bookmarks
78 if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
80 Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
81 if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
83 m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
84 OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
85 "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
86 m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
90 catch (const Exception&)
95 OResultSet::~OResultSet()
97 m_pColumns->acquire();
98 m_pColumns->disposing();
99 delete m_pColumns;
103 // com::sun::star::lang::XTypeProvider
104 Sequence< Type > OResultSet::getTypes() throw (RuntimeException, std::exception)
106 OTypeCollection aTypes(cppu::UnoType<XPropertySet>::get(),
107 OResultSetBase::getTypes());
109 return aTypes.getTypes();
112 Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException, std::exception)
114 return css::uno::Sequence<sal_Int8>();
117 // com::sun::star::uno::XInterface
118 Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
120 Any aIface = OResultSetBase::queryInterface( rType );
121 if (!aIface.hasValue())
122 aIface = ::cppu::queryInterface(
123 rType,
124 static_cast< XPropertySet * >( this ));
126 return aIface;
129 void OResultSet::acquire() throw ()
131 OResultSetBase::acquire();
134 void OResultSet::release() throw ()
136 OResultSetBase::release();
140 // OResultSetBase
141 void OResultSet::disposing()
143 OPropertySetHelper::disposing();
145 MutexGuard aGuard(m_aMutex);
147 // free the columns
148 m_pColumns->disposing();
150 // close the pending result set
151 Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
153 m_xDelegatorResultSet = NULL;
154 m_xDelegatorRow = NULL;
155 m_xDelegatorRowUpdate = NULL;
157 m_aStatement.clear();
160 // XCloseable
161 void OResultSet::close() throw( SQLException, RuntimeException, std::exception )
164 MutexGuard aGuard( m_aMutex );
165 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
167 dispose();
170 // XServiceInfo
171 OUString OResultSet::getImplementationName( ) throw(RuntimeException, std::exception)
173 return OUString("com.sun.star.sdb.OResultSet");
176 sal_Bool OResultSet::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
178 return cppu::supportsService(this, _rServiceName);
181 Sequence< OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
183 Sequence< OUString > aSNS( 2 );
184 aSNS[0] = SERVICE_SDBC_RESULTSET;
185 aSNS[1] = SERVICE_SDB_RESULTSET;
186 return aSNS;
189 // com::sun::star::beans::XPropertySet
190 Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException, std::exception)
192 return createPropertySetInfo( getInfoHelper() ) ;
195 // comphelper::OPropertyArrayUsageHelper
196 ::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
198 BEGIN_PROPERTY_HELPER(6)
199 DECL_PROP1(CURSORNAME, OUString, READONLY);
200 DECL_PROP0(FETCHDIRECTION, sal_Int32);
201 DECL_PROP0(FETCHSIZE, sal_Int32);
202 DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
203 DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
204 DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
205 END_PROPERTY_HELPER();
208 // cppu::OPropertySetHelper
209 ::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
211 return *getArrayHelper();
214 sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
216 // be lazy ...
217 rConvertedValue = rValue;
218 getFastPropertyValue( rOldValue, nHandle );
219 return sal_True;
222 void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception, std::exception)
224 // set it for the driver result set
225 Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
226 switch (nHandle)
228 case PROPERTY_ID_FETCHDIRECTION:
229 xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
230 break;
231 case PROPERTY_ID_FETCHSIZE:
232 xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
233 break;
234 default:
235 SAL_WARN("dbaccess", "unknown Property");
239 void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
241 switch (nHandle)
243 case PROPERTY_ID_ISBOOKMARKABLE:
245 sal_Bool bVal = m_bIsBookmarkable;
246 rValue.setValue(&bVal, cppu::UnoType<bool>::get());
247 } break;
248 default:
250 // get the property name
251 OUString aPropName;
252 sal_Int16 nAttributes;
253 const_cast<OResultSet*>(this)->getInfoHelper().
254 fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
255 OSL_ENSURE(!aPropName.isEmpty(), "property not found?");
257 // now read the value
258 rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
263 // XWarningsSupplier
264 Any OResultSet::getWarnings() throw( SQLException, RuntimeException, std::exception )
266 MutexGuard aGuard(m_aMutex);
267 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
268 return m_aWarnings.getWarnings();
271 void OResultSet::clearWarnings() throw( SQLException, RuntimeException, std::exception )
273 MutexGuard aGuard(m_aMutex);
274 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
275 m_aWarnings.clearWarnings();
278 // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
279 Reference< XResultSetMetaData > OResultSet::getMetaData() throw( SQLException, RuntimeException, std::exception )
281 MutexGuard aGuard(m_aMutex);
282 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
284 return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
287 // ::com::sun::star::sdbc::XColumnLocate
288 sal_Int32 OResultSet::findColumn(const OUString& columnName) throw( SQLException, RuntimeException, std::exception )
290 MutexGuard aGuard(m_aMutex);
291 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
293 return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
296 namespace
298 static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
300 Reference< XDatabaseMetaData > xDBMetaData;
303 Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
304 Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
305 Reference< XConnection > xConn;
306 if ( xStatement.is() )
307 xConn = xStatement->getConnection();
308 else if ( xPreparedStatement.is() )
309 xConn = xPreparedStatement->getConnection();
310 if ( xConn.is() )
311 xDBMetaData = xConn->getMetaData();
313 catch( const Exception& )
315 DBG_UNHANDLED_EXCEPTION();
317 return xDBMetaData;
321 // ::com::sun::star::sdbcx::XColumnsSupplier
322 Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns() throw( RuntimeException, std::exception )
324 MutexGuard aGuard(m_aMutex);
325 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
327 // do we have to populate the columns
328 if (!m_pColumns->isInitialized())
330 // get the metadata
331 Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
333 sal_Int32 nColCount = 0;
334 // do we have columns
337 Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
338 nColCount = xMetaData->getColumnCount();
340 for ( sal_Int32 i = 0; i < nColCount; ++i)
342 // retrieve the name of the column
343 OUString sName = xMetaData->getColumnName(i + 1);
344 ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
346 // don't silently assume that the name is unique - result set implementations
347 // are allowed to return duplicate names, but we are required to have
348 // unique column names
349 if ( m_pColumns->hasByName( sName ) )
350 sName = ::dbtools::createUniqueName( m_pColumns, sName );
352 m_pColumns->append( sName, pColumn );
355 catch ( const SQLException& )
357 DBG_UNHANDLED_EXCEPTION();
359 m_pColumns->setInitialized();
361 #if OSL_DEBUG_LEVEL > 0
362 // some sanity checks. Especially in case we auto-adjusted the column names above,
363 // this might be reasonable
366 const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
367 const Sequence< OUString > aNames( xColNames->getElementNames() );
368 SAL_WARN_IF( aNames.getLength() != nColCount, "dbaccess",
369 "OResultSet::getColumns: invalid column count!" );
370 for ( const OUString* pName = aNames.getConstArray();
371 pName != aNames.getConstArray() + aNames.getLength();
372 ++pName
375 Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
376 OUString sName;
377 OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
378 SAL_WARN_IF( sName != *pName, "dbaccess", "OResultSet::getColumns: invalid column name!" );
382 catch( const Exception& )
384 DBG_UNHANDLED_EXCEPTION();
386 #endif
388 return m_pColumns;
391 // ::com::sun::star::sdbc::XRow
392 sal_Bool OResultSet::wasNull() throw( SQLException, RuntimeException, std::exception )
394 MutexGuard aGuard(m_aMutex);
395 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
397 return m_xDelegatorRow->wasNull();
400 OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
402 MutexGuard aGuard(m_aMutex);
403 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
405 return m_xDelegatorRow->getString(columnIndex);
408 sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
410 MutexGuard aGuard(m_aMutex);
411 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
413 return m_xDelegatorRow->getBoolean(columnIndex);
416 sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
418 MutexGuard aGuard(m_aMutex);
419 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
421 return m_xDelegatorRow->getByte(columnIndex);
424 sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
426 MutexGuard aGuard(m_aMutex);
427 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
429 return m_xDelegatorRow->getShort(columnIndex);
432 sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
434 MutexGuard aGuard(m_aMutex);
435 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
437 return m_xDelegatorRow->getInt(columnIndex);
440 sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
442 MutexGuard aGuard(m_aMutex);
443 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
445 return m_xDelegatorRow->getLong(columnIndex);
448 float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
450 MutexGuard aGuard(m_aMutex);
451 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
453 return m_xDelegatorRow->getFloat(columnIndex);
456 double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
458 MutexGuard aGuard(m_aMutex);
459 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
461 return m_xDelegatorRow->getDouble(columnIndex);
464 Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
466 MutexGuard aGuard(m_aMutex);
467 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
469 return m_xDelegatorRow->getBytes(columnIndex);
472 ::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
474 MutexGuard aGuard(m_aMutex);
475 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
477 return m_xDelegatorRow->getDate(columnIndex);
480 ::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
482 MutexGuard aGuard(m_aMutex);
483 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
485 return m_xDelegatorRow->getTime(columnIndex);
488 ::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
490 MutexGuard aGuard(m_aMutex);
491 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
493 return m_xDelegatorRow->getTimestamp(columnIndex);
496 Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
498 MutexGuard aGuard(m_aMutex);
499 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
501 return m_xDelegatorRow->getBinaryStream(columnIndex);
504 Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
506 MutexGuard aGuard(m_aMutex);
507 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
509 return m_xDelegatorRow->getCharacterStream(columnIndex);
512 Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException, std::exception )
514 MutexGuard aGuard(m_aMutex);
515 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
517 return m_xDelegatorRow->getObject(columnIndex, typeMap);
520 Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
522 MutexGuard aGuard(m_aMutex);
523 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
525 return m_xDelegatorRow->getRef(columnIndex);
528 Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
530 MutexGuard aGuard(m_aMutex);
531 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
533 return m_xDelegatorRow->getBlob(columnIndex);
536 Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
538 MutexGuard aGuard(m_aMutex);
539 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
541 return m_xDelegatorRow->getClob(columnIndex);
544 Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
546 MutexGuard aGuard(m_aMutex);
547 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
549 return m_xDelegatorRow->getArray(columnIndex);
552 // ::com::sun::star::sdbc::XRowUpdate
553 void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
555 MutexGuard aGuard(m_aMutex);
556 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
558 checkReadOnly();
560 m_xDelegatorRowUpdate->updateNull(columnIndex);
563 void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException, std::exception )
565 MutexGuard aGuard(m_aMutex);
566 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
568 checkReadOnly();
570 m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
573 void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException, std::exception )
575 MutexGuard aGuard(m_aMutex);
576 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
578 checkReadOnly();
580 m_xDelegatorRowUpdate->updateByte(columnIndex, x);
583 void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException, std::exception )
585 MutexGuard aGuard(m_aMutex);
586 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
588 checkReadOnly();
590 m_xDelegatorRowUpdate->updateShort(columnIndex, x);
593 void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException, std::exception )
595 MutexGuard aGuard(m_aMutex);
596 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
598 checkReadOnly();
600 m_xDelegatorRowUpdate->updateInt(columnIndex, x);
603 void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException, std::exception )
605 MutexGuard aGuard(m_aMutex);
606 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
608 checkReadOnly();
610 m_xDelegatorRowUpdate->updateLong(columnIndex, x);
613 void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException, std::exception )
615 MutexGuard aGuard(m_aMutex);
616 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
618 checkReadOnly();
620 m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
623 void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException, std::exception )
625 MutexGuard aGuard(m_aMutex);
626 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
628 checkReadOnly();
630 m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
633 void OResultSet::updateString(sal_Int32 columnIndex, const OUString& x) throw( SQLException, RuntimeException, std::exception )
635 MutexGuard aGuard(m_aMutex);
636 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
638 checkReadOnly();
640 m_xDelegatorRowUpdate->updateString(columnIndex, x);
643 void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException, std::exception )
645 MutexGuard aGuard(m_aMutex);
646 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
648 checkReadOnly();
650 m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
653 void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException, std::exception )
655 MutexGuard aGuard(m_aMutex);
656 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
658 checkReadOnly();
660 m_xDelegatorRowUpdate->updateDate(columnIndex, x);
663 void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException, std::exception )
665 MutexGuard aGuard(m_aMutex);
666 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
668 checkReadOnly();
670 m_xDelegatorRowUpdate->updateTime(columnIndex, x);
673 void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException, std::exception )
675 MutexGuard aGuard(m_aMutex);
676 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
678 checkReadOnly();
680 m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
683 void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
685 MutexGuard aGuard(m_aMutex);
686 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
688 checkReadOnly();
690 m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
693 void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
695 MutexGuard aGuard(m_aMutex);
696 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
698 checkReadOnly();
700 m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
703 void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException, std::exception )
705 MutexGuard aGuard(m_aMutex);
706 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
708 checkReadOnly();
710 m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
713 void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException, std::exception )
715 MutexGuard aGuard(m_aMutex);
716 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
718 checkReadOnly();
720 m_xDelegatorRowUpdate->updateObject(columnIndex, x);
723 // ::com::sun::star::sdbc::XResultSet
724 sal_Bool OResultSet::next() throw( SQLException, RuntimeException, std::exception )
726 MutexGuard aGuard(m_aMutex);
727 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
729 return m_xDelegatorResultSet->next();
732 sal_Bool OResultSet::isBeforeFirst() throw( SQLException, RuntimeException, std::exception )
734 MutexGuard aGuard(m_aMutex);
735 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
737 return m_xDelegatorResultSet->isBeforeFirst();
740 sal_Bool OResultSet::isAfterLast() throw( SQLException, RuntimeException, std::exception )
742 MutexGuard aGuard(m_aMutex);
743 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
745 return m_xDelegatorResultSet->isAfterLast();
748 sal_Bool OResultSet::isFirst() throw( SQLException, RuntimeException, std::exception )
750 MutexGuard aGuard(m_aMutex);
751 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
753 return m_xDelegatorResultSet->isFirst();
756 sal_Bool OResultSet::isLast() throw( SQLException, RuntimeException, std::exception )
758 MutexGuard aGuard(m_aMutex);
759 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
761 return m_xDelegatorResultSet->isLast();
764 void OResultSet::beforeFirst() throw( SQLException, RuntimeException, std::exception )
766 MutexGuard aGuard(m_aMutex);
767 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
769 m_xDelegatorResultSet->beforeFirst();
772 void OResultSet::afterLast() throw( SQLException, RuntimeException, std::exception )
774 MutexGuard aGuard(m_aMutex);
775 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
777 m_xDelegatorResultSet->afterLast();
780 sal_Bool OResultSet::first() throw( SQLException, RuntimeException, std::exception )
782 MutexGuard aGuard(m_aMutex);
783 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
785 return m_xDelegatorResultSet->first();
788 sal_Bool OResultSet::last() throw( SQLException, RuntimeException, std::exception )
790 MutexGuard aGuard(m_aMutex);
791 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
793 return m_xDelegatorResultSet->last();
796 sal_Int32 OResultSet::getRow() throw( SQLException, RuntimeException, std::exception )
798 MutexGuard aGuard(m_aMutex);
799 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
801 return m_xDelegatorResultSet->getRow();
804 sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException, std::exception )
806 MutexGuard aGuard(m_aMutex);
807 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
809 return m_xDelegatorResultSet->absolute(row);
812 sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
814 MutexGuard aGuard(m_aMutex);
815 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
817 return m_xDelegatorResultSet->relative(rows);
820 sal_Bool OResultSet::previous() throw( SQLException, RuntimeException, std::exception )
822 MutexGuard aGuard(m_aMutex);
823 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
825 return m_xDelegatorResultSet->previous();
828 void OResultSet::refreshRow() throw( SQLException, RuntimeException, std::exception )
830 MutexGuard aGuard(m_aMutex);
831 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
833 m_xDelegatorResultSet->refreshRow();
836 sal_Bool OResultSet::rowUpdated() throw( SQLException, RuntimeException, std::exception )
838 MutexGuard aGuard(m_aMutex);
839 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
841 return m_xDelegatorResultSet->rowUpdated();
844 sal_Bool OResultSet::rowInserted() throw( SQLException, RuntimeException, std::exception )
846 MutexGuard aGuard(m_aMutex);
847 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
849 return m_xDelegatorResultSet->rowInserted();
852 sal_Bool OResultSet::rowDeleted() throw( SQLException, RuntimeException, std::exception )
854 MutexGuard aGuard(m_aMutex);
855 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
857 return m_xDelegatorResultSet->rowDeleted();
860 Reference< XInterface > OResultSet::getStatement() throw( SQLException, RuntimeException, std::exception )
862 MutexGuard aGuard(m_aMutex);
863 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
865 return m_aStatement;
868 // ::com::sun::star::sdbcx::XRowLocate
869 Any OResultSet::getBookmark() throw( SQLException, RuntimeException, std::exception )
871 MutexGuard aGuard(m_aMutex);
872 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
874 checkBookmarkable();
876 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
879 sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
881 MutexGuard aGuard(m_aMutex);
882 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
884 checkBookmarkable();
886 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
889 sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
891 MutexGuard aGuard(m_aMutex);
892 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
894 checkBookmarkable();
896 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
899 sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException, std::exception )
901 MutexGuard aGuard(m_aMutex);
902 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
904 checkBookmarkable();
906 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
909 sal_Bool OResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException, std::exception )
911 MutexGuard aGuard(m_aMutex);
912 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
914 checkBookmarkable();
916 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
919 sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
921 MutexGuard aGuard(m_aMutex);
922 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
924 checkBookmarkable();
926 return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
929 // ::com::sun::star::sdbc::XResultSetUpdate
930 void OResultSet::insertRow() throw( SQLException, RuntimeException, std::exception )
932 MutexGuard aGuard(m_aMutex);
933 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
935 checkReadOnly();
937 m_xDelegatorResultSetUpdate->insertRow();
940 void OResultSet::updateRow() throw( SQLException, RuntimeException, std::exception )
942 MutexGuard aGuard(m_aMutex);
943 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
945 checkReadOnly();
947 m_xDelegatorResultSetUpdate->updateRow();
950 void OResultSet::deleteRow() throw( SQLException, RuntimeException, std::exception )
952 MutexGuard aGuard(m_aMutex);
953 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
955 checkReadOnly();
957 m_xDelegatorResultSetUpdate->deleteRow();
960 void OResultSet::cancelRowUpdates() throw( SQLException, RuntimeException, std::exception )
962 MutexGuard aGuard(m_aMutex);
963 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
965 checkReadOnly();
967 m_xDelegatorResultSetUpdate->cancelRowUpdates();
970 void OResultSet::moveToInsertRow() throw( SQLException, RuntimeException, std::exception )
972 MutexGuard aGuard(m_aMutex);
973 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
975 checkReadOnly();
977 m_xDelegatorResultSetUpdate->moveToInsertRow();
980 void OResultSet::moveToCurrentRow() throw( SQLException, RuntimeException, std::exception )
982 MutexGuard aGuard(m_aMutex);
983 ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
985 checkReadOnly();
987 m_xDelegatorResultSetUpdate->moveToCurrentRow();
990 void OResultSet::checkReadOnly() const
992 if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
993 || !m_xDelegatorResultSetUpdate.is()
995 throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
998 void OResultSet::checkBookmarkable() const
1000 if ( !m_bIsBookmarkable )
1001 throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
1004 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */