Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / ado / AStatement.cxx
blob2c95b70914ebca1ffe7069d44effd2bed106935a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AStatement.cxx,v $
10 * $Revision: 1.30 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "ado/AStatement.hxx"
34 #include "ado/AConnection.hxx"
35 #include "ado/AResultSet.hxx"
36 #include <comphelper/property.hxx>
37 #include <comphelper/uno3.hxx>
38 #include <osl/thread.h>
39 #include <cppuhelper/typeprovider.hxx>
40 #include <comphelper/sequence.hxx>
41 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
42 #include <com/sun/star/sdbc/ResultSetType.hpp>
43 #include <com/sun/star/sdbc/FetchDirection.hpp>
44 #include "connectivity/dbexception.hxx"
45 #include <comphelper/types.hxx>
47 #undef max
49 #include <algorithm>
51 using namespace ::comphelper;
53 #define CHECK_RETURN(x) \
54 if(!x) \
55 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
59 using namespace connectivity::ado;
61 //------------------------------------------------------------------------------
62 using namespace com::sun::star::uno;
63 using namespace com::sun::star::lang;
64 using namespace com::sun::star::beans;
65 using namespace com::sun::star::sdbc;
66 using namespace ::std;
67 //------------------------------------------------------------------------------
68 OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex)
69 ,OPropertySetHelper(OStatement_BASE::rBHelper)
70 ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this)
71 ,m_pConnection(_pConnection)
72 ,m_nFetchSize(1)
73 ,m_nMaxRows(0)
74 ,m_eLockType(adLockReadOnly)
75 ,m_eCursorType(adOpenForwardOnly)
77 osl_incrementInterlockedCount( &m_refCount );
79 m_Command.Create();
80 if(m_Command.IsValid())
81 m_Command.putref_ActiveConnection(m_pConnection->getConnection());
82 else
83 ADOS::ThrowException(*m_pConnection->getConnection(),*this);
85 m_RecordsAffected.setNoArg();
86 m_Parameters.setNoArg();
88 m_pConnection->acquire();
90 osl_decrementInterlockedCount( &m_refCount );
92 //------------------------------------------------------------------------------
93 void OStatement_Base::disposeResultSet()
95 // free the cursor if alive
96 Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
97 if (xComp.is())
98 xComp->dispose();
99 m_xResultSet = Reference< XResultSet>();
102 //------------------------------------------------------------------------------
103 void OStatement_Base::disposing()
105 ::osl::MutexGuard aGuard(m_aMutex);
108 disposeResultSet();
110 if ( m_Command.IsValid() )
111 m_Command.putref_ActiveConnection( NULL );
112 m_Command.clear();
114 if ( m_RecordSet.IsValid() )
115 m_RecordSet.PutRefDataSource( NULL );
116 m_RecordSet.clear();
118 if (m_pConnection)
119 m_pConnection->release();
121 dispose_ChildImpl();
122 OStatement_BASE::disposing();
124 //-----------------------------------------------------------------------------
125 void SAL_CALL OStatement_Base::release() throw()
127 relase_ChildImpl();
129 //-----------------------------------------------------------------------------
130 Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
132 Any aRet = OStatement_BASE::queryInterface(rType);
133 return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
135 // -------------------------------------------------------------------------
136 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
138 ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
139 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
140 ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
142 return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
145 // -------------------------------------------------------------------------
147 void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
149 ::osl::MutexGuard aGuard( m_aMutex );
150 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
153 CHECK_RETURN(m_Command.Cancel())
155 // -------------------------------------------------------------------------
157 void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
160 ::osl::MutexGuard aGuard( m_aMutex );
161 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
164 dispose();
166 // -------------------------------------------------------------------------
168 void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
172 // -------------------------------------------------------------------------
174 void OStatement_Base::reset() throw (SQLException)
176 ::osl::MutexGuard aGuard( m_aMutex );
177 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
180 clearWarnings ();
182 if (m_xResultSet.get().is())
183 clearMyResultSet();
185 //--------------------------------------------------------------------
186 // clearMyResultSet
187 // If a ResultSet was created for this Statement, close it
188 //--------------------------------------------------------------------
190 void OStatement_Base::clearMyResultSet () throw (SQLException)
192 ::osl::MutexGuard aGuard( m_aMutex );
193 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
197 Reference<XCloseable> xCloseable;
198 if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
199 xCloseable->close();
201 catch( const DisposedException& ) { }
203 m_xResultSet = Reference< XResultSet >();
205 //--------------------------------------------------------------------
206 sal_Int32 OStatement_Base::getRowCount () throw( SQLException)
208 ::osl::MutexGuard aGuard( m_aMutex );
209 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
212 return m_RecordsAffected;
214 //--------------------------------------------------------------------
215 // getPrecision
216 // Given a SQL type, return the maximum precision for the column.
217 // Returns -1 if not known
218 //--------------------------------------------------------------------
220 sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType)
222 ::osl::MutexGuard aGuard( m_aMutex );
223 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
226 sal_Int32 prec = -1;
227 OTypeInfo aInfo;
228 aInfo.nType = (sal_Int16)sqlType;
229 if (!m_aTypeInfo.empty())
231 ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
232 for(;aIter != m_aTypeInfo.end();++aIter)
234 prec = ::std::max(prec,(*aIter).nPrecision);
238 return prec;
240 //--------------------------------------------------------------------
241 // setWarning
242 // Sets the warning
243 //--------------------------------------------------------------------
245 void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
247 ::osl::MutexGuard aGuard( m_aMutex );
248 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
251 m_aLastWarning = ex;
253 // -------------------------------------------------------------------------
254 void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
256 WpADORecordset aOldRS( m_RecordSet );
257 m_RecordSet = WpADORecordset( _pRS );
259 if ( aOldRS.IsValid() )
260 aOldRS.PutRefDataSource( NULL );
262 if ( m_RecordSet.IsValid() )
263 m_RecordSet.PutRefDataSource( (IDispatch*)m_Command );
265 // -------------------------------------------------------------------------
266 sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
268 ::osl::MutexGuard aGuard( m_aMutex );
269 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
272 // Reset the statement handle and warning
274 reset();
278 ADORecordset* pSet = NULL;
279 CHECK_RETURN(m_Command.put_CommandText(sql))
280 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet))
282 assignRecordSet( pSet );
284 catch (SQLWarning& ex)
287 // Save pointer to warning and save with ResultSet
288 // object once it is created.
290 m_aLastWarning = ex;
293 return m_RecordSet.IsValid();
295 // -------------------------------------------------------------------------
296 Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
298 ::osl::MutexGuard aGuard( m_aMutex );
299 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
302 reset();
304 m_xResultSet = WeakReference<XResultSet>(NULL);
306 WpADORecordset aSet;
307 aSet.Create();
308 CHECK_RETURN(m_Command.put_CommandText(sql))
309 OLEVariant aCmd;
310 aCmd.setIDispatch(m_Command);
311 OLEVariant aCon;
312 aCon.setNoArg();
313 CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize))
314 CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows))
315 CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
318 CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize))
319 CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows))
320 CHECK_RETURN(aSet.get_CursorType(m_eCursorType))
321 CHECK_RETURN(aSet.get_LockType(m_eLockType))
323 OResultSet* pSet = new OResultSet(aSet,this);
324 Reference< XResultSet > xRs = pSet;
325 pSet->construct();
327 m_xResultSet = WeakReference<XResultSet>(xRs);
329 return xRs;
331 // -------------------------------------------------------------------------
333 Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
335 ::osl::MutexGuard aGuard( m_aMutex );
336 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
339 return (Reference< XConnection >)m_pConnection;
341 // -------------------------------------------------------------------------
343 Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
345 Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
346 return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
348 // -------------------------------------------------------------------------
350 void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
352 ::osl::MutexGuard aGuard( m_aMutex );
353 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
356 m_aBatchList.push_back(sql);
358 // -------------------------------------------------------------------------
359 Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
361 ::osl::MutexGuard aGuard( m_aMutex );
362 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
365 reset();
367 ::rtl::OUString aBatchSql;
368 sal_Int32 nLen = 0;
369 for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
370 aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";");
373 if ( m_RecordSet.IsValid() )
374 m_RecordSet.PutRefDataSource( NULL );
375 m_RecordSet.clear();
376 m_RecordSet.Create();
378 CHECK_RETURN(m_Command.put_CommandText(aBatchSql))
379 if ( m_RecordSet.IsValid() )
380 m_RecordSet.PutRefDataSource((IDispatch*)m_Command);
382 CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
384 ADORecordset* pSet=NULL;
385 Sequence< sal_Int32 > aRet(nLen);
386 sal_Int32* pArray = aRet.getArray();
387 for(sal_Int32 j=0;j<nLen;++j)
389 pSet = NULL;
390 OLEVariant aRecordsAffected;
391 if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
393 assignRecordSet( pSet );
395 sal_Int32 nValue;
396 if(m_RecordSet.get_RecordCount(nValue))
397 pArray[j] = nValue;
400 return aRet;
402 // -------------------------------------------------------------------------
405 sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
407 ::osl::MutexGuard aGuard( m_aMutex );
408 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
411 reset();
413 try {
414 ADORecordset* pSet = NULL;
415 CHECK_RETURN(m_Command.put_CommandText(sql))
416 CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet))
418 catch (SQLWarning& ex) {
420 // Save pointer to warning and save with ResultSet
421 // object once it is created.
423 m_aLastWarning = ex;
425 if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR)
426 return m_RecordsAffected;
428 return 0;
430 // -------------------------------------------------------------------------
432 Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException)
434 ::osl::MutexGuard aGuard( m_aMutex );
435 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
438 return m_xResultSet;
440 // -------------------------------------------------------------------------
442 sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException)
444 ::osl::MutexGuard aGuard( m_aMutex );
445 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
448 sal_Int32 nRet;
449 if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
450 return nRet;
451 return -1;
453 // -------------------------------------------------------------------------
455 sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException)
457 ::osl::MutexGuard aGuard( m_aMutex );
458 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
461 SQLWarning warning;
463 // clear previous warnings
465 clearWarnings ();
467 // Call SQLMoreResults
471 ADORecordset* pSet=NULL;
472 OLEVariant aRecordsAffected;
473 if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
474 assignRecordSet( pSet );
476 catch (SQLWarning &ex)
479 // Save pointer to warning and save with ResultSet
480 // object once it is created.
482 warning = ex;
484 return m_RecordSet.IsValid();
486 // -------------------------------------------------------------------------
488 // -------------------------------------------------------------------------
489 Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
491 ::osl::MutexGuard aGuard( m_aMutex );
492 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
495 return makeAny(m_aLastWarning);
497 // -------------------------------------------------------------------------
499 // -------------------------------------------------------------------------
500 void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
502 ::osl::MutexGuard aGuard( m_aMutex );
503 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
506 m_aLastWarning = SQLWarning();
508 // -------------------------------------------------------------------------
509 //------------------------------------------------------------------------------
510 sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException)
512 return m_Command.get_CommandTimeout();
514 //------------------------------------------------------------------------------
515 sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException)
517 sal_Int32 nRet=-1;
518 if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
519 ::dbtools::throwFunctionSequenceException(NULL);
520 return nRet;
522 //------------------------------------------------------------------------------
523 sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException)
525 return m_eLockType;
526 sal_Int32 nValue=0;
527 switch(m_eLockType)
529 case adLockReadOnly:
530 nValue = ResultSetConcurrency::READ_ONLY;
531 break;
532 default:
533 nValue = ResultSetConcurrency::UPDATABLE;
534 break;
537 return nValue;
539 //------------------------------------------------------------------------------
540 sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException)
542 sal_Int32 nValue=0;
543 switch(m_eCursorType)
545 case adOpenUnspecified:
546 case adOpenForwardOnly:
547 nValue = ResultSetType::FORWARD_ONLY;
548 break;
549 case adOpenStatic:
550 case adOpenKeyset:
551 nValue = ResultSetType::SCROLL_INSENSITIVE;
552 break;
553 case adOpenDynamic:
554 nValue = ResultSetType::SCROLL_SENSITIVE;
555 break;
557 return nValue;
559 //------------------------------------------------------------------------------
560 sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException)
562 return FetchDirection::FORWARD;
564 //------------------------------------------------------------------------------
565 sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException)
567 return m_nFetchSize;
569 //------------------------------------------------------------------------------
570 sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException)
572 return 0;
574 //------------------------------------------------------------------------------
575 ::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException)
577 return m_Command.GetName();
579 //------------------------------------------------------------------------------
580 void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException)
582 ::osl::MutexGuard aGuard( m_aMutex );
583 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
586 m_Command.put_CommandTimeout(seconds);
588 //------------------------------------------------------------------------------
589 void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
591 ::osl::MutexGuard aGuard( m_aMutex );
592 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
594 m_nMaxRows = _par0;
596 //------------------------------------------------------------------------------
597 void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
599 ::osl::MutexGuard aGuard( m_aMutex );
600 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
602 switch(_par0)
604 case ResultSetConcurrency::READ_ONLY:
605 m_eLockType = adLockReadOnly;
606 break;
607 default:
608 m_eLockType = adLockOptimistic;
609 break;
612 //------------------------------------------------------------------------------
613 void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
615 ::osl::MutexGuard aGuard( m_aMutex );
616 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
619 switch(_par0)
621 case ResultSetType::FORWARD_ONLY:
622 m_eCursorType = adOpenForwardOnly;
623 break;
624 case ResultSetType::SCROLL_INSENSITIVE:
625 m_eCursorType = adOpenKeyset;
626 break;
627 case ResultSetType::SCROLL_SENSITIVE:
628 m_eCursorType = adOpenDynamic;
629 break;
632 //------------------------------------------------------------------------------
633 void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
635 ::osl::MutexGuard aGuard( m_aMutex );
636 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
637 ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this );
639 //------------------------------------------------------------------------------
640 void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
642 ::osl::MutexGuard aGuard( m_aMutex );
643 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
646 m_nFetchSize = _par0;
647 // m_RecordSet.put_CacheSize(_par0);
649 //------------------------------------------------------------------------------
650 void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
652 ::osl::MutexGuard aGuard( m_aMutex );
653 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
654 ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this );
656 //------------------------------------------------------------------------------
657 void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
659 ::osl::MutexGuard aGuard( m_aMutex );
660 checkDisposed(OStatement_BASE::rBHelper.bDisposed);
662 m_Command.put_Name(_par0);
665 // -------------------------------------------------------------------------
666 ::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
668 Sequence< com::sun::star::beans::Property > aProps(10);
669 com::sun::star::beans::Property* pProperties = aProps.getArray();
670 sal_Int32 nPos = 0;
671 DECL_PROP0(CURSORNAME, ::rtl::OUString);
672 DECL_BOOL_PROP0(ESCAPEPROCESSING);
673 DECL_PROP0(FETCHDIRECTION,sal_Int32);
674 DECL_PROP0(FETCHSIZE, sal_Int32);
675 DECL_PROP0(MAXFIELDSIZE,sal_Int32);
676 DECL_PROP0(MAXROWS, sal_Int32);
677 DECL_PROP0(QUERYTIMEOUT,sal_Int32);
678 DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
679 DECL_PROP0(RESULTSETTYPE,sal_Int32);
680 DECL_BOOL_PROP0(USEBOOKMARKS);
683 return new ::cppu::OPropertyArrayHelper(aProps);
686 // -------------------------------------------------------------------------
687 ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
689 return *const_cast<OStatement_Base*>(this)->getArrayHelper();
691 // -------------------------------------------------------------------------
692 sal_Bool OStatement_Base::convertFastPropertyValue(
693 Any & rConvertedValue,
694 Any & rOldValue,
695 sal_Int32 nHandle,
696 const Any& rValue )
697 throw (::com::sun::star::lang::IllegalArgumentException)
699 sal_Bool bModified = sal_False;
701 sal_Bool bValidAdoRS = m_RecordSet.IsValid();
702 // some of the properties below, when set, are remembered in a member, and applied in the next execute
703 // For these properties, the record set does not need to be valid to allow setting them.
704 // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid.
708 switch(nHandle)
710 case PROPERTY_ID_MAXROWS:
711 bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows );
712 break;
714 case PROPERTY_ID_RESULTSETTYPE:
715 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
716 break;
717 case PROPERTY_ID_FETCHSIZE:
718 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
719 break;
720 case PROPERTY_ID_RESULTSETCONCURRENCY:
721 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
722 break;
723 case PROPERTY_ID_QUERYTIMEOUT:
724 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
725 break;
726 case PROPERTY_ID_MAXFIELDSIZE:
727 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
728 break;
729 case PROPERTY_ID_CURSORNAME:
730 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
731 break;
732 case PROPERTY_ID_FETCHDIRECTION:
733 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
734 break;
737 catch( const Exception& e )
739 bModified = sal_True; // will ensure that the property is set
740 OSL_ENSURE( sal_False, "OStatement_Base::convertFastPropertyValue: caught something strange!" );
741 (void)e;
743 return bModified;
745 // -------------------------------------------------------------------------
746 void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
748 switch(nHandle)
750 case PROPERTY_ID_QUERYTIMEOUT:
751 setQueryTimeOut(comphelper::getINT32(rValue));
752 break;
753 case PROPERTY_ID_MAXFIELDSIZE:
754 setMaxFieldSize(comphelper::getINT32(rValue));
755 break;
756 case PROPERTY_ID_MAXROWS:
757 setMaxRows(comphelper::getINT32(rValue));
758 break;
759 case PROPERTY_ID_CURSORNAME:
760 setCursorName(comphelper::getString(rValue));
761 break;
762 case PROPERTY_ID_RESULTSETCONCURRENCY:
763 setResultSetConcurrency(comphelper::getINT32(rValue));
764 break;
765 case PROPERTY_ID_RESULTSETTYPE:
766 setResultSetType(comphelper::getINT32(rValue));
767 break;
768 case PROPERTY_ID_FETCHDIRECTION:
769 setFetchDirection(comphelper::getINT32(rValue));
770 break;
771 case PROPERTY_ID_FETCHSIZE:
772 setFetchSize(comphelper::getINT32(rValue));
773 break;
774 case PROPERTY_ID_ESCAPEPROCESSING:
775 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
776 case PROPERTY_ID_USEBOOKMARKS:
777 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
778 default:
782 // -------------------------------------------------------------------------
783 void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
785 switch(nHandle)
787 case PROPERTY_ID_QUERYTIMEOUT:
788 rValue <<= getQueryTimeOut();
789 break;
790 case PROPERTY_ID_MAXFIELDSIZE:
791 rValue <<= getMaxFieldSize();
792 break;
793 case PROPERTY_ID_MAXROWS:
794 rValue <<= getMaxRows();
795 break;
796 case PROPERTY_ID_CURSORNAME:
797 rValue <<= getCursorName();
798 break;
799 case PROPERTY_ID_RESULTSETCONCURRENCY:
800 rValue <<= getResultSetConcurrency();
801 break;
802 case PROPERTY_ID_RESULTSETTYPE:
803 rValue <<= getResultSetType();
804 break;
805 case PROPERTY_ID_FETCHDIRECTION:
806 rValue <<= getFetchDirection();
807 break;
808 case PROPERTY_ID_FETCHSIZE:
809 rValue <<= getFetchSize();
810 break;
811 case PROPERTY_ID_ESCAPEPROCESSING:
812 rValue <<= sal_True;
813 break;
814 case PROPERTY_ID_USEBOOKMARKS:
815 default:
819 // -------------------------------------------------------------------------
820 OStatement::~OStatement()
823 IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
824 // -----------------------------------------------------------------------------
825 void SAL_CALL OStatement_Base::acquire() throw()
827 OStatement_BASE::acquire();
829 // -----------------------------------------------------------------------------
830 void SAL_CALL OStatement::acquire() throw()
832 OStatement_Base::acquire();
834 // -----------------------------------------------------------------------------
835 void SAL_CALL OStatement::release() throw()
837 OStatement_Base::release();
839 // -----------------------------------------------------------------------------
840 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
842 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
844 // -----------------------------------------------------------------------------