xref: /trunk/main/connectivity/source/drivers/ado/AStatement.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include "ado/AStatement.hxx"
31*cdf0e10cSrcweir #include "ado/AConnection.hxx"
32*cdf0e10cSrcweir #include "ado/AResultSet.hxx"
33*cdf0e10cSrcweir #include <comphelper/property.hxx>
34*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
35*cdf0e10cSrcweir #include <osl/thread.h>
36*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
37*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
38*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
41*cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
42*cdf0e10cSrcweir #include <comphelper/types.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #undef max
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <algorithm>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using namespace ::comphelper;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define CHECK_RETURN(x)                                                 \
51*cdf0e10cSrcweir     if(!x)                                                              \
52*cdf0e10cSrcweir         ADOS::ThrowException(*m_pConnection->getConnection(),*this);
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir using namespace connectivity::ado;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //------------------------------------------------------------------------------
59*cdf0e10cSrcweir using namespace com::sun::star::uno;
60*cdf0e10cSrcweir using namespace com::sun::star::lang;
61*cdf0e10cSrcweir using namespace com::sun::star::beans;
62*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
63*cdf0e10cSrcweir using namespace ::std;
64*cdf0e10cSrcweir //------------------------------------------------------------------------------
65*cdf0e10cSrcweir OStatement_Base::OStatement_Base(OConnection* _pConnection ) :  OStatement_BASE(m_aMutex)
66*cdf0e10cSrcweir                                                         ,OPropertySetHelper(OStatement_BASE::rBHelper)
67*cdf0e10cSrcweir                                                         ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this)
68*cdf0e10cSrcweir                                                         ,m_pConnection(_pConnection)
69*cdf0e10cSrcweir                                                         ,m_nFetchSize(1)
70*cdf0e10cSrcweir                                                         ,m_nMaxRows(0)
71*cdf0e10cSrcweir                                                         ,m_eLockType(adLockReadOnly)
72*cdf0e10cSrcweir                                                         ,m_eCursorType(adOpenForwardOnly)
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     osl_incrementInterlockedCount( &m_refCount );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     m_Command.Create();
77*cdf0e10cSrcweir     if(m_Command.IsValid())
78*cdf0e10cSrcweir         m_Command.putref_ActiveConnection(m_pConnection->getConnection());
79*cdf0e10cSrcweir     else
80*cdf0e10cSrcweir         ADOS::ThrowException(*m_pConnection->getConnection(),*this);
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir     m_RecordsAffected.setNoArg();
83*cdf0e10cSrcweir     m_Parameters.setNoArg();
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     m_pConnection->acquire();
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir     osl_decrementInterlockedCount( &m_refCount );
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir //------------------------------------------------------------------------------
90*cdf0e10cSrcweir void OStatement_Base::disposeResultSet()
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir     // free the cursor if alive
93*cdf0e10cSrcweir     Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
94*cdf0e10cSrcweir     if (xComp.is())
95*cdf0e10cSrcweir         xComp->dispose();
96*cdf0e10cSrcweir     m_xResultSet = Reference< XResultSet>();
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir //------------------------------------------------------------------------------
100*cdf0e10cSrcweir void OStatement_Base::disposing()
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     disposeResultSet();
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     if ( m_Command.IsValid() )
108*cdf0e10cSrcweir         m_Command.putref_ActiveConnection( NULL );
109*cdf0e10cSrcweir     m_Command.clear();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     if ( m_RecordSet.IsValid() )
112*cdf0e10cSrcweir         m_RecordSet.PutRefDataSource( NULL );
113*cdf0e10cSrcweir     m_RecordSet.clear();
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     if (m_pConnection)
116*cdf0e10cSrcweir         m_pConnection->release();
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     dispose_ChildImpl();
119*cdf0e10cSrcweir     OStatement_BASE::disposing();
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir //-----------------------------------------------------------------------------
122*cdf0e10cSrcweir void SAL_CALL OStatement_Base::release() throw()
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir     relase_ChildImpl();
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir //-----------------------------------------------------------------------------
127*cdf0e10cSrcweir Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     Any aRet = OStatement_BASE::queryInterface(rType);
130*cdf0e10cSrcweir     return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir // -------------------------------------------------------------------------
133*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes(  ) throw(::com::sun::star::uno::RuntimeException)
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
136*cdf0e10cSrcweir                                     ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
137*cdf0e10cSrcweir                                     ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir     return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir // -------------------------------------------------------------------------
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir void SAL_CALL OStatement_Base::cancel(  ) throw(RuntimeException)
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
147*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     CHECK_RETURN(m_Command.Cancel())
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir // -------------------------------------------------------------------------
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir void SAL_CALL OStatement_Base::close(  ) throw(SQLException, RuntimeException)
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     {
157*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
158*cdf0e10cSrcweir         checkDisposed(OStatement_BASE::rBHelper.bDisposed);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     }
161*cdf0e10cSrcweir     dispose();
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir // -------------------------------------------------------------------------
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir void SAL_CALL OStatement::clearBatch(  ) throw(SQLException, RuntimeException)
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir // -------------------------------------------------------------------------
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir void OStatement_Base::reset() throw (SQLException)
172*cdf0e10cSrcweir {
173*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
174*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     clearWarnings ();
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     if (m_xResultSet.get().is())
180*cdf0e10cSrcweir         clearMyResultSet();
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir //--------------------------------------------------------------------
183*cdf0e10cSrcweir // clearMyResultSet
184*cdf0e10cSrcweir // If a ResultSet was created for this Statement, close it
185*cdf0e10cSrcweir //--------------------------------------------------------------------
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir void OStatement_Base::clearMyResultSet () throw (SQLException)
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
190*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     try
193*cdf0e10cSrcweir     {
194*cdf0e10cSrcweir         Reference<XCloseable> xCloseable;
195*cdf0e10cSrcweir         if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
196*cdf0e10cSrcweir             xCloseable->close();
197*cdf0e10cSrcweir     }
198*cdf0e10cSrcweir     catch( const DisposedException& ) { }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir     m_xResultSet = Reference< XResultSet >();
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir //--------------------------------------------------------------------
203*cdf0e10cSrcweir sal_Int32 OStatement_Base::getRowCount () throw( SQLException)
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
206*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     return m_RecordsAffected;
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir //--------------------------------------------------------------------
212*cdf0e10cSrcweir // getPrecision
213*cdf0e10cSrcweir // Given a SQL type, return the maximum precision for the column.
214*cdf0e10cSrcweir // Returns -1 if not known
215*cdf0e10cSrcweir //--------------------------------------------------------------------
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType)
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
220*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     sal_Int32 prec = -1;
224*cdf0e10cSrcweir     OTypeInfo aInfo;
225*cdf0e10cSrcweir     aInfo.nType = (sal_Int16)sqlType;
226*cdf0e10cSrcweir     if (!m_aTypeInfo.empty())
227*cdf0e10cSrcweir     {
228*cdf0e10cSrcweir         ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
229*cdf0e10cSrcweir         for(;aIter != m_aTypeInfo.end();++aIter)
230*cdf0e10cSrcweir         {
231*cdf0e10cSrcweir             prec = ::std::max(prec,(*aIter).nPrecision);
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     return prec;
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir //--------------------------------------------------------------------
238*cdf0e10cSrcweir // setWarning
239*cdf0e10cSrcweir // Sets the warning
240*cdf0e10cSrcweir //--------------------------------------------------------------------
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
245*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     m_aLastWarning = ex;
249*cdf0e10cSrcweir }
250*cdf0e10cSrcweir // -------------------------------------------------------------------------
251*cdf0e10cSrcweir void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir     WpADORecordset aOldRS( m_RecordSet );
254*cdf0e10cSrcweir     m_RecordSet = WpADORecordset( _pRS );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     if ( aOldRS.IsValid() )
257*cdf0e10cSrcweir         aOldRS.PutRefDataSource( NULL );
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir     if ( m_RecordSet.IsValid() )
260*cdf0e10cSrcweir         m_RecordSet.PutRefDataSource( (IDispatch*)m_Command );
261*cdf0e10cSrcweir }
262*cdf0e10cSrcweir // -------------------------------------------------------------------------
263*cdf0e10cSrcweir sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
266*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     // Reset the statement handle and warning
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     reset();
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir     try
274*cdf0e10cSrcweir     {
275*cdf0e10cSrcweir         ADORecordset* pSet = NULL;
276*cdf0e10cSrcweir         CHECK_RETURN(m_Command.put_CommandText(sql))
277*cdf0e10cSrcweir         CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet))
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir         assignRecordSet( pSet );
280*cdf0e10cSrcweir     }
281*cdf0e10cSrcweir     catch (SQLWarning& ex)
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir         // Save pointer to warning and save with ResultSet
285*cdf0e10cSrcweir         // object once it is created.
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         m_aLastWarning = ex;
288*cdf0e10cSrcweir     }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir     return m_RecordSet.IsValid();
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir // -------------------------------------------------------------------------
293*cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
296*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir     reset();
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     m_xResultSet = WeakReference<XResultSet>(NULL);
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     WpADORecordset aSet;
304*cdf0e10cSrcweir     aSet.Create();
305*cdf0e10cSrcweir     CHECK_RETURN(m_Command.put_CommandText(sql))
306*cdf0e10cSrcweir     OLEVariant aCmd;
307*cdf0e10cSrcweir     aCmd.setIDispatch(m_Command);
308*cdf0e10cSrcweir     OLEVariant aCon;
309*cdf0e10cSrcweir     aCon.setNoArg();
310*cdf0e10cSrcweir     CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize))
311*cdf0e10cSrcweir     CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows))
312*cdf0e10cSrcweir     CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize))
316*cdf0e10cSrcweir     CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows))
317*cdf0e10cSrcweir     CHECK_RETURN(aSet.get_CursorType(m_eCursorType))
318*cdf0e10cSrcweir     CHECK_RETURN(aSet.get_LockType(m_eLockType))
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     OResultSet* pSet = new OResultSet(aSet,this);
321*cdf0e10cSrcweir     Reference< XResultSet > xRs = pSet;
322*cdf0e10cSrcweir     pSet->construct();
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     m_xResultSet = WeakReference<XResultSet>(xRs);
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     return xRs;
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir // -------------------------------------------------------------------------
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir Reference< XConnection > SAL_CALL OStatement_Base::getConnection(  ) throw(SQLException, RuntimeException)
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
333*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     return (Reference< XConnection >)m_pConnection;
337*cdf0e10cSrcweir }
338*cdf0e10cSrcweir // -------------------------------------------------------------------------
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir     Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
343*cdf0e10cSrcweir     return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir // -------------------------------------------------------------------------
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
348*cdf0e10cSrcweir {
349*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
350*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     m_aBatchList.push_back(sql);
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir // -------------------------------------------------------------------------
356*cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch(  ) throw(SQLException, RuntimeException)
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
359*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     reset();
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     ::rtl::OUString aBatchSql;
365*cdf0e10cSrcweir     sal_Int32 nLen = 0;
366*cdf0e10cSrcweir     for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
367*cdf0e10cSrcweir         aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";");
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir     if ( m_RecordSet.IsValid() )
371*cdf0e10cSrcweir         m_RecordSet.PutRefDataSource( NULL );
372*cdf0e10cSrcweir     m_RecordSet.clear();
373*cdf0e10cSrcweir     m_RecordSet.Create();
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     CHECK_RETURN(m_Command.put_CommandText(aBatchSql))
376*cdf0e10cSrcweir     if ( m_RecordSet.IsValid() )
377*cdf0e10cSrcweir         m_RecordSet.PutRefDataSource((IDispatch*)m_Command);
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir     ADORecordset* pSet=NULL;
382*cdf0e10cSrcweir     Sequence< sal_Int32 > aRet(nLen);
383*cdf0e10cSrcweir     sal_Int32* pArray = aRet.getArray();
384*cdf0e10cSrcweir     for(sal_Int32 j=0;j<nLen;++j)
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         pSet = NULL;
387*cdf0e10cSrcweir         OLEVariant aRecordsAffected;
388*cdf0e10cSrcweir         if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
389*cdf0e10cSrcweir         {
390*cdf0e10cSrcweir             assignRecordSet( pSet );
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir             sal_Int32 nValue;
393*cdf0e10cSrcweir             if(m_RecordSet.get_RecordCount(nValue))
394*cdf0e10cSrcweir                 pArray[j] = nValue;
395*cdf0e10cSrcweir         }
396*cdf0e10cSrcweir     }
397*cdf0e10cSrcweir     return aRet;
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir // -------------------------------------------------------------------------
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
403*cdf0e10cSrcweir {
404*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
405*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     reset();
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     try {
411*cdf0e10cSrcweir         ADORecordset* pSet = NULL;
412*cdf0e10cSrcweir         CHECK_RETURN(m_Command.put_CommandText(sql))
413*cdf0e10cSrcweir         CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet))
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir     catch (SQLWarning& ex) {
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir         // Save pointer to warning and save with ResultSet
418*cdf0e10cSrcweir         // object once it is created.
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir         m_aLastWarning = ex;
421*cdf0e10cSrcweir     }
422*cdf0e10cSrcweir     if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR)
423*cdf0e10cSrcweir         return m_RecordsAffected;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     return 0;
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir // -------------------------------------------------------------------------
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet(  ) throw(SQLException, RuntimeException)
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
432*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir     return m_xResultSet;
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir // -------------------------------------------------------------------------
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir sal_Int32 SAL_CALL OStatement_Base::getUpdateCount(  ) throw(SQLException, RuntimeException)
440*cdf0e10cSrcweir {
441*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
442*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir     sal_Int32 nRet;
446*cdf0e10cSrcweir     if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
447*cdf0e10cSrcweir         return nRet;
448*cdf0e10cSrcweir     return -1;
449*cdf0e10cSrcweir }
450*cdf0e10cSrcweir // -------------------------------------------------------------------------
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir sal_Bool SAL_CALL OStatement_Base::getMoreResults(  ) throw(SQLException, RuntimeException)
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
455*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     SQLWarning  warning;
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     // clear previous warnings
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir     clearWarnings ();
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir     // Call SQLMoreResults
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir     try
467*cdf0e10cSrcweir     {
468*cdf0e10cSrcweir         ADORecordset* pSet=NULL;
469*cdf0e10cSrcweir         OLEVariant aRecordsAffected;
470*cdf0e10cSrcweir         if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
471*cdf0e10cSrcweir             assignRecordSet( pSet );
472*cdf0e10cSrcweir     }
473*cdf0e10cSrcweir     catch (SQLWarning &ex)
474*cdf0e10cSrcweir     {
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir         // Save pointer to warning and save with ResultSet
477*cdf0e10cSrcweir         // object once it is created.
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir         warning = ex;
480*cdf0e10cSrcweir     }
481*cdf0e10cSrcweir     return m_RecordSet.IsValid();
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir // -------------------------------------------------------------------------
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir // -------------------------------------------------------------------------
486*cdf0e10cSrcweir Any SAL_CALL OStatement_Base::getWarnings(  ) throw(SQLException, RuntimeException)
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
489*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir     return makeAny(m_aLastWarning);
493*cdf0e10cSrcweir }
494*cdf0e10cSrcweir // -------------------------------------------------------------------------
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir // -------------------------------------------------------------------------
497*cdf0e10cSrcweir void SAL_CALL OStatement_Base::clearWarnings(  ) throw(SQLException, RuntimeException)
498*cdf0e10cSrcweir {
499*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
500*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     m_aLastWarning = SQLWarning();
504*cdf0e10cSrcweir }
505*cdf0e10cSrcweir // -------------------------------------------------------------------------
506*cdf0e10cSrcweir //------------------------------------------------------------------------------
507*cdf0e10cSrcweir sal_Int32 OStatement_Base::getQueryTimeOut() const  throw(SQLException, RuntimeException)
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir     return m_Command.get_CommandTimeout();
510*cdf0e10cSrcweir }
511*cdf0e10cSrcweir //------------------------------------------------------------------------------
512*cdf0e10cSrcweir sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException)
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir     sal_Int32 nRet=-1;
515*cdf0e10cSrcweir     if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
516*cdf0e10cSrcweir         ::dbtools::throwFunctionSequenceException(NULL);
517*cdf0e10cSrcweir     return nRet;
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir //------------------------------------------------------------------------------
520*cdf0e10cSrcweir sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException)
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir     return m_eLockType;
523*cdf0e10cSrcweir     sal_Int32 nValue=0;
524*cdf0e10cSrcweir     switch(m_eLockType)
525*cdf0e10cSrcweir     {
526*cdf0e10cSrcweir         case adLockReadOnly:
527*cdf0e10cSrcweir             nValue = ResultSetConcurrency::READ_ONLY;
528*cdf0e10cSrcweir             break;
529*cdf0e10cSrcweir         default:
530*cdf0e10cSrcweir             nValue = ResultSetConcurrency::UPDATABLE;
531*cdf0e10cSrcweir             break;
532*cdf0e10cSrcweir     }
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir     return nValue;
535*cdf0e10cSrcweir }
536*cdf0e10cSrcweir //------------------------------------------------------------------------------
537*cdf0e10cSrcweir sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException)
538*cdf0e10cSrcweir {
539*cdf0e10cSrcweir     sal_Int32 nValue=0;
540*cdf0e10cSrcweir     switch(m_eCursorType)
541*cdf0e10cSrcweir     {
542*cdf0e10cSrcweir         case adOpenUnspecified:
543*cdf0e10cSrcweir         case adOpenForwardOnly:
544*cdf0e10cSrcweir             nValue = ResultSetType::FORWARD_ONLY;
545*cdf0e10cSrcweir             break;
546*cdf0e10cSrcweir         case adOpenStatic:
547*cdf0e10cSrcweir         case adOpenKeyset:
548*cdf0e10cSrcweir             nValue = ResultSetType::SCROLL_INSENSITIVE;
549*cdf0e10cSrcweir             break;
550*cdf0e10cSrcweir         case adOpenDynamic:
551*cdf0e10cSrcweir             nValue = ResultSetType::SCROLL_SENSITIVE;
552*cdf0e10cSrcweir             break;
553*cdf0e10cSrcweir     }
554*cdf0e10cSrcweir     return nValue;
555*cdf0e10cSrcweir }
556*cdf0e10cSrcweir //------------------------------------------------------------------------------
557*cdf0e10cSrcweir sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException)
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir     return FetchDirection::FORWARD;
560*cdf0e10cSrcweir }
561*cdf0e10cSrcweir //------------------------------------------------------------------------------
562*cdf0e10cSrcweir sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException)
563*cdf0e10cSrcweir {
564*cdf0e10cSrcweir     return m_nFetchSize;
565*cdf0e10cSrcweir }
566*cdf0e10cSrcweir //------------------------------------------------------------------------------
567*cdf0e10cSrcweir sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException)
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir     return 0;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir //------------------------------------------------------------------------------
572*cdf0e10cSrcweir ::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException)
573*cdf0e10cSrcweir {
574*cdf0e10cSrcweir     return m_Command.GetName();
575*cdf0e10cSrcweir }
576*cdf0e10cSrcweir //------------------------------------------------------------------------------
577*cdf0e10cSrcweir void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException)
578*cdf0e10cSrcweir {
579*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
580*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir     m_Command.put_CommandTimeout(seconds);
584*cdf0e10cSrcweir }
585*cdf0e10cSrcweir //------------------------------------------------------------------------------
586*cdf0e10cSrcweir void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
587*cdf0e10cSrcweir {
588*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
589*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     m_nMaxRows = _par0;
592*cdf0e10cSrcweir }
593*cdf0e10cSrcweir //------------------------------------------------------------------------------
594*cdf0e10cSrcweir void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
597*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir     switch(_par0)
600*cdf0e10cSrcweir     {
601*cdf0e10cSrcweir         case ResultSetConcurrency::READ_ONLY:
602*cdf0e10cSrcweir             m_eLockType = adLockReadOnly;
603*cdf0e10cSrcweir             break;
604*cdf0e10cSrcweir         default:
605*cdf0e10cSrcweir             m_eLockType = adLockOptimistic;
606*cdf0e10cSrcweir             break;
607*cdf0e10cSrcweir     }
608*cdf0e10cSrcweir }
609*cdf0e10cSrcweir //------------------------------------------------------------------------------
610*cdf0e10cSrcweir void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
611*cdf0e10cSrcweir {
612*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
613*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir     switch(_par0)
617*cdf0e10cSrcweir     {
618*cdf0e10cSrcweir         case ResultSetType::FORWARD_ONLY:
619*cdf0e10cSrcweir             m_eCursorType = adOpenForwardOnly;
620*cdf0e10cSrcweir             break;
621*cdf0e10cSrcweir         case ResultSetType::SCROLL_INSENSITIVE:
622*cdf0e10cSrcweir             m_eCursorType = adOpenKeyset;
623*cdf0e10cSrcweir             break;
624*cdf0e10cSrcweir         case ResultSetType::SCROLL_SENSITIVE:
625*cdf0e10cSrcweir             m_eCursorType = adOpenDynamic;
626*cdf0e10cSrcweir             break;
627*cdf0e10cSrcweir     }
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir //------------------------------------------------------------------------------
630*cdf0e10cSrcweir void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
631*cdf0e10cSrcweir {
632*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
633*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
634*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this );
635*cdf0e10cSrcweir }
636*cdf0e10cSrcweir //------------------------------------------------------------------------------
637*cdf0e10cSrcweir void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
640*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     m_nFetchSize = _par0;
644*cdf0e10cSrcweir     //  m_RecordSet.put_CacheSize(_par0);
645*cdf0e10cSrcweir }
646*cdf0e10cSrcweir //------------------------------------------------------------------------------
647*cdf0e10cSrcweir void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
650*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
651*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this );
652*cdf0e10cSrcweir }
653*cdf0e10cSrcweir //------------------------------------------------------------------------------
654*cdf0e10cSrcweir void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
655*cdf0e10cSrcweir {
656*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
657*cdf0e10cSrcweir     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir     m_Command.put_Name(_par0);
660*cdf0e10cSrcweir }
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir // -------------------------------------------------------------------------
663*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
664*cdf0e10cSrcweir {
665*cdf0e10cSrcweir     Sequence< com::sun::star::beans::Property > aProps(10);
666*cdf0e10cSrcweir     com::sun::star::beans::Property* pProperties = aProps.getArray();
667*cdf0e10cSrcweir     sal_Int32 nPos = 0;
668*cdf0e10cSrcweir     DECL_PROP0(CURSORNAME,  ::rtl::OUString);
669*cdf0e10cSrcweir     DECL_BOOL_PROP0(ESCAPEPROCESSING);
670*cdf0e10cSrcweir     DECL_PROP0(FETCHDIRECTION,sal_Int32);
671*cdf0e10cSrcweir     DECL_PROP0(FETCHSIZE,   sal_Int32);
672*cdf0e10cSrcweir     DECL_PROP0(MAXFIELDSIZE,sal_Int32);
673*cdf0e10cSrcweir     DECL_PROP0(MAXROWS,     sal_Int32);
674*cdf0e10cSrcweir     DECL_PROP0(QUERYTIMEOUT,sal_Int32);
675*cdf0e10cSrcweir     DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
676*cdf0e10cSrcweir     DECL_PROP0(RESULTSETTYPE,sal_Int32);
677*cdf0e10cSrcweir     DECL_BOOL_PROP0(USEBOOKMARKS);
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir     return new ::cppu::OPropertyArrayHelper(aProps);
681*cdf0e10cSrcweir }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir // -------------------------------------------------------------------------
684*cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir     return *const_cast<OStatement_Base*>(this)->getArrayHelper();
687*cdf0e10cSrcweir }
688*cdf0e10cSrcweir // -------------------------------------------------------------------------
689*cdf0e10cSrcweir sal_Bool OStatement_Base::convertFastPropertyValue(
690*cdf0e10cSrcweir                             Any & rConvertedValue,
691*cdf0e10cSrcweir                             Any & rOldValue,
692*cdf0e10cSrcweir                             sal_Int32 nHandle,
693*cdf0e10cSrcweir                             const Any& rValue )
694*cdf0e10cSrcweir                                 throw (::com::sun::star::lang::IllegalArgumentException)
695*cdf0e10cSrcweir {
696*cdf0e10cSrcweir     sal_Bool bModified = sal_False;
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir     sal_Bool bValidAdoRS = m_RecordSet.IsValid();
699*cdf0e10cSrcweir         // some of the properties below, when set, are remembered in a member, and applied in the next execute
700*cdf0e10cSrcweir         // For these properties, the record set does not need to be valid to allow setting them.
701*cdf0e10cSrcweir         // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid.
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir     try
704*cdf0e10cSrcweir     {
705*cdf0e10cSrcweir         switch(nHandle)
706*cdf0e10cSrcweir         {
707*cdf0e10cSrcweir             case PROPERTY_ID_MAXROWS:
708*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows );
709*cdf0e10cSrcweir                 break;
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir             case PROPERTY_ID_RESULTSETTYPE:
712*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
713*cdf0e10cSrcweir                 break;
714*cdf0e10cSrcweir             case PROPERTY_ID_FETCHSIZE:
715*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
716*cdf0e10cSrcweir                 break;
717*cdf0e10cSrcweir             case PROPERTY_ID_RESULTSETCONCURRENCY:
718*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
719*cdf0e10cSrcweir                 break;
720*cdf0e10cSrcweir             case PROPERTY_ID_QUERYTIMEOUT:
721*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
722*cdf0e10cSrcweir                 break;
723*cdf0e10cSrcweir             case PROPERTY_ID_MAXFIELDSIZE:
724*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
725*cdf0e10cSrcweir                 break;
726*cdf0e10cSrcweir             case PROPERTY_ID_CURSORNAME:
727*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
728*cdf0e10cSrcweir                 break;
729*cdf0e10cSrcweir             case PROPERTY_ID_FETCHDIRECTION:
730*cdf0e10cSrcweir                 bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
731*cdf0e10cSrcweir                 break;
732*cdf0e10cSrcweir         }
733*cdf0e10cSrcweir     }
734*cdf0e10cSrcweir     catch( const Exception& e )
735*cdf0e10cSrcweir     {
736*cdf0e10cSrcweir         bModified = sal_True;   // will ensure that the property is set
737*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "OStatement_Base::convertFastPropertyValue: caught something strange!" );
738*cdf0e10cSrcweir         (void)e;
739*cdf0e10cSrcweir     }
740*cdf0e10cSrcweir     return bModified;
741*cdf0e10cSrcweir }
742*cdf0e10cSrcweir // -------------------------------------------------------------------------
743*cdf0e10cSrcweir void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
744*cdf0e10cSrcweir {
745*cdf0e10cSrcweir     switch(nHandle)
746*cdf0e10cSrcweir     {
747*cdf0e10cSrcweir         case PROPERTY_ID_QUERYTIMEOUT:
748*cdf0e10cSrcweir             setQueryTimeOut(comphelper::getINT32(rValue));
749*cdf0e10cSrcweir             break;
750*cdf0e10cSrcweir         case PROPERTY_ID_MAXFIELDSIZE:
751*cdf0e10cSrcweir             setMaxFieldSize(comphelper::getINT32(rValue));
752*cdf0e10cSrcweir             break;
753*cdf0e10cSrcweir         case PROPERTY_ID_MAXROWS:
754*cdf0e10cSrcweir             setMaxRows(comphelper::getINT32(rValue));
755*cdf0e10cSrcweir             break;
756*cdf0e10cSrcweir         case PROPERTY_ID_CURSORNAME:
757*cdf0e10cSrcweir             setCursorName(comphelper::getString(rValue));
758*cdf0e10cSrcweir             break;
759*cdf0e10cSrcweir         case PROPERTY_ID_RESULTSETCONCURRENCY:
760*cdf0e10cSrcweir             setResultSetConcurrency(comphelper::getINT32(rValue));
761*cdf0e10cSrcweir             break;
762*cdf0e10cSrcweir         case PROPERTY_ID_RESULTSETTYPE:
763*cdf0e10cSrcweir             setResultSetType(comphelper::getINT32(rValue));
764*cdf0e10cSrcweir             break;
765*cdf0e10cSrcweir         case PROPERTY_ID_FETCHDIRECTION:
766*cdf0e10cSrcweir             setFetchDirection(comphelper::getINT32(rValue));
767*cdf0e10cSrcweir             break;
768*cdf0e10cSrcweir         case PROPERTY_ID_FETCHSIZE:
769*cdf0e10cSrcweir             setFetchSize(comphelper::getINT32(rValue));
770*cdf0e10cSrcweir             break;
771*cdf0e10cSrcweir         case PROPERTY_ID_ESCAPEPROCESSING:
772*cdf0e10cSrcweir             //  return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
773*cdf0e10cSrcweir         case PROPERTY_ID_USEBOOKMARKS:
774*cdf0e10cSrcweir             //  return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
775*cdf0e10cSrcweir         default:
776*cdf0e10cSrcweir             ;
777*cdf0e10cSrcweir     }
778*cdf0e10cSrcweir }
779*cdf0e10cSrcweir // -------------------------------------------------------------------------
780*cdf0e10cSrcweir void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
781*cdf0e10cSrcweir {
782*cdf0e10cSrcweir     switch(nHandle)
783*cdf0e10cSrcweir     {
784*cdf0e10cSrcweir         case PROPERTY_ID_QUERYTIMEOUT:
785*cdf0e10cSrcweir             rValue <<= getQueryTimeOut();
786*cdf0e10cSrcweir             break;
787*cdf0e10cSrcweir         case PROPERTY_ID_MAXFIELDSIZE:
788*cdf0e10cSrcweir             rValue <<= getMaxFieldSize();
789*cdf0e10cSrcweir             break;
790*cdf0e10cSrcweir         case PROPERTY_ID_MAXROWS:
791*cdf0e10cSrcweir             rValue <<= getMaxRows();
792*cdf0e10cSrcweir             break;
793*cdf0e10cSrcweir         case PROPERTY_ID_CURSORNAME:
794*cdf0e10cSrcweir             rValue <<= getCursorName();
795*cdf0e10cSrcweir             break;
796*cdf0e10cSrcweir         case PROPERTY_ID_RESULTSETCONCURRENCY:
797*cdf0e10cSrcweir             rValue <<= getResultSetConcurrency();
798*cdf0e10cSrcweir             break;
799*cdf0e10cSrcweir         case PROPERTY_ID_RESULTSETTYPE:
800*cdf0e10cSrcweir             rValue <<= getResultSetType();
801*cdf0e10cSrcweir             break;
802*cdf0e10cSrcweir         case PROPERTY_ID_FETCHDIRECTION:
803*cdf0e10cSrcweir             rValue <<= getFetchDirection();
804*cdf0e10cSrcweir             break;
805*cdf0e10cSrcweir         case PROPERTY_ID_FETCHSIZE:
806*cdf0e10cSrcweir             rValue <<= getFetchSize();
807*cdf0e10cSrcweir             break;
808*cdf0e10cSrcweir         case PROPERTY_ID_ESCAPEPROCESSING:
809*cdf0e10cSrcweir             rValue <<= sal_True;
810*cdf0e10cSrcweir             break;
811*cdf0e10cSrcweir         case PROPERTY_ID_USEBOOKMARKS:
812*cdf0e10cSrcweir         default:
813*cdf0e10cSrcweir             ;
814*cdf0e10cSrcweir     }
815*cdf0e10cSrcweir }
816*cdf0e10cSrcweir // -------------------------------------------------------------------------
817*cdf0e10cSrcweir OStatement::~OStatement()
818*cdf0e10cSrcweir {
819*cdf0e10cSrcweir }
820*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
821*cdf0e10cSrcweir // -----------------------------------------------------------------------------
822*cdf0e10cSrcweir void SAL_CALL OStatement_Base::acquire() throw()
823*cdf0e10cSrcweir {
824*cdf0e10cSrcweir     OStatement_BASE::acquire();
825*cdf0e10cSrcweir }
826*cdf0e10cSrcweir // -----------------------------------------------------------------------------
827*cdf0e10cSrcweir void SAL_CALL OStatement::acquire() throw()
828*cdf0e10cSrcweir {
829*cdf0e10cSrcweir     OStatement_Base::acquire();
830*cdf0e10cSrcweir }
831*cdf0e10cSrcweir // -----------------------------------------------------------------------------
832*cdf0e10cSrcweir void SAL_CALL OStatement::release() throw()
833*cdf0e10cSrcweir {
834*cdf0e10cSrcweir     OStatement_Base::release();
835*cdf0e10cSrcweir }
836*cdf0e10cSrcweir // -----------------------------------------------------------------------------
837*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
838*cdf0e10cSrcweir {
839*cdf0e10cSrcweir     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
840*cdf0e10cSrcweir }
841*cdf0e10cSrcweir // -----------------------------------------------------------------------------
842