Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / AStatement.cxx
blob03e06a0a0b931711e9c16584f617f0db90fccfc7
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 "ado/AStatement.hxx"
21 #include "ado/AConnection.hxx"
22 #include "ado/AResultSet.hxx"
23 #include <comphelper/property.hxx>
24 #include <comphelper/uno3.hxx>
25 #include <osl/thread.h>
26 #include <cppuhelper/typeprovider.hxx>
27 #include <comphelper/sequence.hxx>
28 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
29 #include <com/sun/star/sdbc/ResultSetType.hpp>
30 #include <com/sun/star/sdbc/FetchDirection.hpp>
31 #include "connectivity/dbexception.hxx"
32 #include <comphelper/types.hxx>
34 #undef max
36 #include <algorithm>
38 using namespace ::comphelper;
40 #define CHECK_RETURN(x) \
41 if(!x) \
42 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
46 using namespace connectivity::ado;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::lang;
51 using namespace com::sun::star::beans;
52 using namespace com::sun::star::sdbc;
53 using namespace ::std;
55 OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex)
56 ,OPropertySetHelper(OStatement_BASE::rBHelper)
57 ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this)
58 ,m_pConnection(_pConnection)
59 ,m_nMaxRows(0)
60 ,m_nFetchSize(1)
61 ,m_eLockType(adLockReadOnly)
62 ,m_eCursorType(adOpenForwardOnly)
64 osl_atomic_increment( &m_refCount );
66 m_Command.Create();
67 if(m_Command.IsValid())
68 m_Command.putref_ActiveConnection(m_pConnection->getConnection());
69 else
70 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
72 m_RecordsAffected.setNoArg();
73 m_Parameters.setNoArg();
75 m_pConnection->acquire();
77 osl_atomic_decrement( &m_refCount );
80 void OStatement_Base::disposeResultSet()
82 // free the cursor if alive
83 Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
84 if (xComp.is())
85 xComp->dispose();
86 m_xResultSet.clear();
90 void OStatement_Base::disposing()
92 ::osl::MutexGuard aGuard(m_aMutex);
95 disposeResultSet();
97 if ( m_Command.IsValid() )
98 m_Command.putref_ActiveConnection( NULL );
99 m_Command.clear();
101 if ( m_RecordSet.IsValid() )
102 m_RecordSet.PutRefDataSource( NULL );
103 m_RecordSet.clear();
105 if (m_pConnection)
106 m_pConnection->release();
108 dispose_ChildImpl();
109 OStatement_BASE::disposing();
112 void SAL_CALL OStatement_Base::release() throw()
114 relase_ChildImpl();
117 Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
119 Any aRet = OStatement_BASE::queryInterface(rType);
120 return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
123 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
125 ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
126 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
127 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
129 return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
134 void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
136 ::osl::MutexGuard aGuard( m_aMutex );
137 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
140 CHECK_RETURN(m_Command.Cancel())
144 void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
147 ::osl::MutexGuard aGuard( m_aMutex );
148 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
151 dispose();
155 void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
161 void OStatement_Base::reset() throw (SQLException)
163 ::osl::MutexGuard aGuard( m_aMutex );
164 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
167 clearWarnings ();
169 if (m_xResultSet.get().is())
170 clearMyResultSet();
173 // clearMyResultSet
174 // If a ResultSet was created for this Statement, close it
177 void OStatement_Base::clearMyResultSet () throw (SQLException)
179 ::osl::MutexGuard aGuard( m_aMutex );
180 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
184 Reference<XCloseable> xCloseable;
185 if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
186 xCloseable->close();
188 catch( const DisposedException& ) { }
190 m_xResultSet.clear();
193 sal_Int32 OStatement_Base::getRowCount () throw( SQLException)
195 ::osl::MutexGuard aGuard( m_aMutex );
196 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
199 return m_RecordsAffected;
202 // getPrecision
203 // Given a SQL type, return the maximum precision for the column.
204 // Returns -1 if not known
207 sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType)
209 ::osl::MutexGuard aGuard( m_aMutex );
210 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
213 sal_Int32 prec = -1;
214 OTypeInfo aInfo;
215 aInfo.nType = (sal_Int16)sqlType;
216 if (!m_aTypeInfo.empty())
218 ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
219 for(;aIter != m_aTypeInfo.end();++aIter)
221 prec = ::std::max(prec,(*aIter).nPrecision);
225 return prec;
228 // setWarning
229 // Sets the warning
232 void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
234 ::osl::MutexGuard aGuard( m_aMutex );
235 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
238 m_aLastWarning = ex;
241 void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
243 WpADORecordset aOldRS( m_RecordSet );
244 m_RecordSet = WpADORecordset( _pRS );
246 if ( aOldRS.IsValid() )
247 aOldRS.PutRefDataSource( NULL );
249 if ( m_RecordSet.IsValid() )
250 m_RecordSet.PutRefDataSource( (IDispatch*)m_Command );
253 sal_Bool SAL_CALL OStatement_Base::execute( const OUString& sql ) throw(SQLException, RuntimeException)
255 ::osl::MutexGuard aGuard( m_aMutex );
256 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
259 // Reset the statement handle and warning
261 reset();
265 ADORecordset* pSet = NULL;
266 CHECK_RETURN(m_Command.put_CommandText(sql))
267 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet))
269 assignRecordSet( pSet );
271 catch (SQLWarning& ex)
274 // Save pointer to warning and save with ResultSet
275 // object once it is created.
277 m_aLastWarning = ex;
280 return m_RecordSet.IsValid();
283 Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const OUString& sql ) throw(SQLException, RuntimeException)
285 ::osl::MutexGuard aGuard( m_aMutex );
286 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
289 reset();
291 m_xResultSet = WeakReference<XResultSet>(NULL);
293 WpADORecordset aSet;
294 aSet.Create();
295 CHECK_RETURN(m_Command.put_CommandText(sql))
296 OLEVariant aCmd;
297 aCmd.setIDispatch(m_Command);
298 OLEVariant aCon;
299 aCon.setNoArg();
300 CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize))
301 CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows))
302 CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
305 CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize))
306 CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows))
307 CHECK_RETURN(aSet.get_CursorType(m_eCursorType))
308 CHECK_RETURN(aSet.get_LockType(m_eLockType))
310 OResultSet* pSet = new OResultSet(aSet,this);
311 Reference< XResultSet > xRs = pSet;
312 pSet->construct();
314 m_xResultSet = WeakReference<XResultSet>(xRs);
316 return xRs;
320 Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
322 ::osl::MutexGuard aGuard( m_aMutex );
323 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
326 return (Reference< XConnection >)m_pConnection;
330 Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
332 Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
333 return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
337 void SAL_CALL OStatement::addBatch( const OUString& sql ) throw(SQLException, RuntimeException)
339 ::osl::MutexGuard aGuard( m_aMutex );
340 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
343 m_aBatchList.push_back(sql);
346 Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
348 ::osl::MutexGuard aGuard( m_aMutex );
349 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
352 reset();
354 OUString aBatchSql;
355 sal_Int32 nLen = 0;
356 for(::std::list< OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
357 aBatchSql = aBatchSql + *i + ";";
360 if ( m_RecordSet.IsValid() )
361 m_RecordSet.PutRefDataSource( NULL );
362 m_RecordSet.clear();
363 m_RecordSet.Create();
365 CHECK_RETURN(m_Command.put_CommandText(aBatchSql))
366 if ( m_RecordSet.IsValid() )
367 m_RecordSet.PutRefDataSource((IDispatch*)m_Command);
369 CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
371 ADORecordset* pSet=NULL;
372 Sequence< sal_Int32 > aRet(nLen);
373 sal_Int32* pArray = aRet.getArray();
374 for(sal_Int32 j=0;j<nLen;++j)
376 pSet = NULL;
377 OLEVariant aRecordsAffected;
378 if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
380 assignRecordSet( pSet );
382 ADO_LONGPTR nValue;
383 if(m_RecordSet.get_RecordCount(nValue))
384 pArray[j] = nValue;
387 return aRet;
392 sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const OUString& sql ) throw(SQLException, RuntimeException)
394 ::osl::MutexGuard aGuard( m_aMutex );
395 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
398 reset();
400 try {
401 ADORecordset* pSet = NULL;
402 CHECK_RETURN(m_Command.put_CommandText(sql))
403 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet))
405 catch (SQLWarning& ex) {
407 // Save pointer to warning and save with ResultSet
408 // object once it is created.
410 m_aLastWarning = ex;
412 if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR)
413 return m_RecordsAffected;
415 return 0;
419 Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException)
421 ::osl::MutexGuard aGuard( m_aMutex );
422 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
425 return m_xResultSet;
429 sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException)
431 ::osl::MutexGuard aGuard( m_aMutex );
432 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
435 ADO_LONGPTR nRet;
436 if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
437 return nRet;
438 return -1;
442 sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException)
444 ::osl::MutexGuard aGuard( m_aMutex );
445 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
448 SQLWarning warning;
450 // clear previous warnings
452 clearWarnings ();
454 // Call SQLMoreResults
458 ADORecordset* pSet=NULL;
459 OLEVariant aRecordsAffected;
460 if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
461 assignRecordSet( pSet );
463 catch (SQLWarning &ex)
466 // Save pointer to warning and save with ResultSet
467 // object once it is created.
469 warning = ex;
471 return m_RecordSet.IsValid();
476 Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
478 ::osl::MutexGuard aGuard( m_aMutex );
479 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
482 return makeAny(m_aLastWarning);
487 void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
489 ::osl::MutexGuard aGuard( m_aMutex );
490 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
493 m_aLastWarning = SQLWarning();
497 sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException)
499 return m_Command.get_CommandTimeout();
502 sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException)
504 ADO_LONGPTR nRet=-1;
505 if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
506 ::dbtools::throwFunctionSequenceException(NULL);
507 return nRet;
510 sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException)
512 sal_Int32 nValue;
514 switch(m_eLockType)
516 case adLockReadOnly:
517 nValue = ResultSetConcurrency::READ_ONLY;
518 break;
519 default:
520 nValue = ResultSetConcurrency::UPDATABLE;
521 break;
524 return nValue;
527 sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException)
529 sal_Int32 nValue=0;
530 switch(m_eCursorType)
532 case adOpenUnspecified:
533 case adOpenForwardOnly:
534 nValue = ResultSetType::FORWARD_ONLY;
535 break;
536 case adOpenStatic:
537 case adOpenKeyset:
538 nValue = ResultSetType::SCROLL_INSENSITIVE;
539 break;
540 case adOpenDynamic:
541 nValue = ResultSetType::SCROLL_SENSITIVE;
542 break;
544 return nValue;
547 sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException)
549 return FetchDirection::FORWARD;
552 sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException)
554 return m_nFetchSize;
557 sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException)
559 return 0;
562 OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException)
564 return m_Command.GetName();
567 void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException)
569 ::osl::MutexGuard aGuard( m_aMutex );
570 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
573 m_Command.put_CommandTimeout(seconds);
576 void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
578 ::osl::MutexGuard aGuard( m_aMutex );
579 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
581 m_nMaxRows = _par0;
584 void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
586 ::osl::MutexGuard aGuard( m_aMutex );
587 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
589 switch(_par0)
591 case ResultSetConcurrency::READ_ONLY:
592 m_eLockType = adLockReadOnly;
593 break;
594 default:
595 m_eLockType = adLockOptimistic;
596 break;
600 void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
602 ::osl::MutexGuard aGuard( m_aMutex );
603 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
606 switch(_par0)
608 case ResultSetType::FORWARD_ONLY:
609 m_eCursorType = adOpenForwardOnly;
610 break;
611 case ResultSetType::SCROLL_INSENSITIVE:
612 m_eCursorType = adOpenKeyset;
613 break;
614 case ResultSetType::SCROLL_SENSITIVE:
615 m_eCursorType = adOpenDynamic;
616 break;
620 void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
622 ::osl::MutexGuard aGuard( m_aMutex );
623 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
624 ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this );
627 void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
629 ::osl::MutexGuard aGuard( m_aMutex );
630 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
633 m_nFetchSize = _par0;
636 void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
638 ::osl::MutexGuard aGuard( m_aMutex );
639 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
640 ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this );
643 void OStatement_Base::setCursorName(const OUString &_par0) throw(SQLException, RuntimeException)
645 ::osl::MutexGuard aGuard( m_aMutex );
646 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
648 m_Command.put_Name(_par0);
652 ::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
654 Sequence< com::sun::star::beans::Property > aProps(10);
655 com::sun::star::beans::Property* pProperties = aProps.getArray();
656 sal_Int32 nPos = 0;
657 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
658 PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0);
659 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),
660 PROPERTY_ID_ESCAPEPROCESSING, ::getBooleanCppuType(), 0);
661 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
662 PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
663 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
664 PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
665 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE),
666 PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0);
667 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS),
668 PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0);
669 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT),
670 PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0);
671 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
672 PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0);
673 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
674 PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
675 pProperties[nPos++] = ::com::sun::star::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS),
676 PROPERTY_ID_USEBOOKMARKS, ::getBooleanCppuType(), 0);
678 return new ::cppu::OPropertyArrayHelper(aProps);
682 ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
684 return *const_cast<OStatement_Base*>(this)->getArrayHelper();
687 sal_Bool OStatement_Base::convertFastPropertyValue(
688 Any & rConvertedValue,
689 Any & rOldValue,
690 sal_Int32 nHandle,
691 const Any& rValue )
692 throw (::com::sun::star::lang::IllegalArgumentException)
694 sal_Bool bModified = sal_False;
696 sal_Bool bValidAdoRS = m_RecordSet.IsValid();
697 // some of the properties below, when set, are remembered in a member, and applied in the next execute
698 // For these properties, the record set does not need to be valid to allow setting them.
699 // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid.
703 switch(nHandle)
705 case PROPERTY_ID_MAXROWS:
706 bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows );
707 break;
709 case PROPERTY_ID_RESULTSETTYPE:
710 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
711 break;
712 case PROPERTY_ID_FETCHSIZE:
713 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
714 break;
715 case PROPERTY_ID_RESULTSETCONCURRENCY:
716 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
717 break;
718 case PROPERTY_ID_QUERYTIMEOUT:
719 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
720 break;
721 case PROPERTY_ID_MAXFIELDSIZE:
722 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
723 break;
724 case PROPERTY_ID_CURSORNAME:
725 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
726 break;
727 case PROPERTY_ID_FETCHDIRECTION:
728 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
729 break;
732 catch( const Exception& e )
734 bModified = sal_True; // will ensure that the property is set
735 OSL_FAIL( "OStatement_Base::convertFastPropertyValue: caught something strange!" );
736 (void)e;
738 return bModified;
741 void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
743 switch(nHandle)
745 case PROPERTY_ID_QUERYTIMEOUT:
746 setQueryTimeOut(comphelper::getINT32(rValue));
747 break;
748 case PROPERTY_ID_MAXFIELDSIZE:
749 setMaxFieldSize(comphelper::getINT32(rValue));
750 break;
751 case PROPERTY_ID_MAXROWS:
752 setMaxRows(comphelper::getINT32(rValue));
753 break;
754 case PROPERTY_ID_CURSORNAME:
755 setCursorName(comphelper::getString(rValue));
756 break;
757 case PROPERTY_ID_RESULTSETCONCURRENCY:
758 setResultSetConcurrency(comphelper::getINT32(rValue));
759 break;
760 case PROPERTY_ID_RESULTSETTYPE:
761 setResultSetType(comphelper::getINT32(rValue));
762 break;
763 case PROPERTY_ID_FETCHDIRECTION:
764 setFetchDirection(comphelper::getINT32(rValue));
765 break;
766 case PROPERTY_ID_FETCHSIZE:
767 setFetchSize(comphelper::getINT32(rValue));
768 break;
769 case PROPERTY_ID_ESCAPEPROCESSING:
770 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
771 case PROPERTY_ID_USEBOOKMARKS:
772 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
773 default:
778 void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
780 switch(nHandle)
782 case PROPERTY_ID_QUERYTIMEOUT:
783 rValue <<= getQueryTimeOut();
784 break;
785 case PROPERTY_ID_MAXFIELDSIZE:
786 rValue <<= getMaxFieldSize();
787 break;
788 case PROPERTY_ID_MAXROWS:
789 rValue <<= getMaxRows();
790 break;
791 case PROPERTY_ID_CURSORNAME:
792 rValue <<= getCursorName();
793 break;
794 case PROPERTY_ID_RESULTSETCONCURRENCY:
795 rValue <<= getResultSetConcurrency();
796 break;
797 case PROPERTY_ID_RESULTSETTYPE:
798 rValue <<= getResultSetType();
799 break;
800 case PROPERTY_ID_FETCHDIRECTION:
801 rValue <<= getFetchDirection();
802 break;
803 case PROPERTY_ID_FETCHSIZE:
804 rValue <<= getFetchSize();
805 break;
806 case PROPERTY_ID_ESCAPEPROCESSING:
807 rValue <<= sal_True;
808 break;
809 case PROPERTY_ID_USEBOOKMARKS:
810 default:
815 OStatement::~OStatement()
818 IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
820 void SAL_CALL OStatement_Base::acquire() throw()
822 OStatement_BASE::acquire();
825 void SAL_CALL OStatement::acquire() throw()
827 OStatement_Base::acquire();
830 void SAL_CALL OStatement::release() throw()
832 OStatement_Base::release();
835 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
837 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
840 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */