1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*96de5490SAndrew Rist * distributed with this work for additional information
6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist * software distributed under the License is distributed on an
15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the
17*96de5490SAndrew Rist * specific language governing permissions and limitations
18*96de5490SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*96de5490SAndrew Rist *************************************************************/
21*96de5490SAndrew Rist
22*96de5490SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef _DBA_COREAPI_STATEMENT_HXX_
27cdf0e10cSrcweir #include <statement.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef _DBA_COREAPI_RESULTSET_HXX_
30cdf0e10cSrcweir #include <resultset.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
33cdf0e10cSrcweir #include "dbastrings.hrc"
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
36cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
39cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
42cdf0e10cSrcweir #include <comphelper/sequence.hxx>
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
45cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _COMPHELPER_PROPERTY_HXX_
48cdf0e10cSrcweir #include <comphelper/property.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_
51cdf0e10cSrcweir #include <comphelper/types.hxx>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX //autogen
54cdf0e10cSrcweir #include <tools/debug.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
57cdf0e10cSrcweir #include <tools/diagnose_ex.h>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_
60cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #include <rtl/logfile.hxx>
63cdf0e10cSrcweir
64cdf0e10cSrcweir using namespace ::com::sun::star::sdb;
65cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
66cdf0e10cSrcweir using namespace ::com::sun::star::beans;
67cdf0e10cSrcweir using namespace ::com::sun::star::uno;
68cdf0e10cSrcweir using namespace ::com::sun::star::lang;
69cdf0e10cSrcweir using namespace ::cppu;
70cdf0e10cSrcweir using namespace ::osl;
71cdf0e10cSrcweir using namespace dbaccess;
72cdf0e10cSrcweir using namespace dbtools;
73cdf0e10cSrcweir
DBG_NAME(OStatementBase)74cdf0e10cSrcweir DBG_NAME(OStatementBase)
75cdf0e10cSrcweir
76cdf0e10cSrcweir //--------------------------------------------------------------------------
77cdf0e10cSrcweir OStatementBase::OStatementBase(const Reference< XConnection > & _xConn,
78cdf0e10cSrcweir const Reference< XInterface > & _xStatement)
79cdf0e10cSrcweir :OSubComponent(m_aMutex, _xConn)
80cdf0e10cSrcweir ,OPropertySetHelper(OComponentHelper::rBHelper)
81cdf0e10cSrcweir ,m_bUseBookmarks( sal_False )
82cdf0e10cSrcweir ,m_bEscapeProcessing( sal_True )
83cdf0e10cSrcweir
84cdf0e10cSrcweir {
85cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::OStatementBase" );
86cdf0e10cSrcweir DBG_CTOR(OStatementBase, NULL);
87cdf0e10cSrcweir OSL_ENSURE(_xStatement.is() ,"Statement is NULL!");
88cdf0e10cSrcweir m_xAggregateAsSet.set(_xStatement,UNO_QUERY);
89cdf0e10cSrcweir m_xAggregateAsCancellable = Reference< ::com::sun::star::util::XCancellable > (m_xAggregateAsSet, UNO_QUERY);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir //--------------------------------------------------------------------------
~OStatementBase()93cdf0e10cSrcweir OStatementBase::~OStatementBase()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir DBG_DTOR(OStatementBase, NULL);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir // com::sun::star::lang::XTypeProvider
99cdf0e10cSrcweir //--------------------------------------------------------------------------
getTypes()100cdf0e10cSrcweir Sequence< Type > OStatementBase::getTypes() throw (RuntimeException)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getTypes" );
103cdf0e10cSrcweir OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ),
104cdf0e10cSrcweir ::getCppuType( (const Reference< XWarningsSupplier > *)0 ),
105cdf0e10cSrcweir ::getCppuType( (const Reference< XCloseable > *)0 ),
106cdf0e10cSrcweir ::getCppuType( (const Reference< XMultipleResults > *)0 ),
107cdf0e10cSrcweir ::getCppuType( (const Reference< ::com::sun::star::util::XCancellable > *)0 ),
108cdf0e10cSrcweir OSubComponent::getTypes() );
109cdf0e10cSrcweir Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
110cdf0e10cSrcweir if ( xGRes.is() )
111cdf0e10cSrcweir aTypes = OTypeCollection(::getCppuType( (const Reference< XGeneratedResultSet > *)0 ),aTypes.getTypes());
112cdf0e10cSrcweir Reference< XPreparedBatchExecution > xPreparedBatchExecution(m_xAggregateAsSet, UNO_QUERY);
113cdf0e10cSrcweir if ( xPreparedBatchExecution.is() )
114cdf0e10cSrcweir aTypes = OTypeCollection(::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ),aTypes.getTypes());
115cdf0e10cSrcweir
116cdf0e10cSrcweir return aTypes.getTypes();
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir // com::sun::star::uno::XInterface
120cdf0e10cSrcweir //--------------------------------------------------------------------------
queryInterface(const Type & rType)121cdf0e10cSrcweir Any OStatementBase::queryInterface( const Type & rType ) throw (RuntimeException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::queryInterface" );
124cdf0e10cSrcweir Any aIface = OSubComponent::queryInterface( rType );
125cdf0e10cSrcweir if (!aIface.hasValue())
126cdf0e10cSrcweir {
127cdf0e10cSrcweir aIface = ::cppu::queryInterface(
128cdf0e10cSrcweir rType,
129cdf0e10cSrcweir static_cast< XPropertySet * >( this ),
130cdf0e10cSrcweir static_cast< XWarningsSupplier * >( this ),
131cdf0e10cSrcweir static_cast< XCloseable * >( this ),
132cdf0e10cSrcweir static_cast< XMultipleResults * >( this ),
133cdf0e10cSrcweir static_cast< ::com::sun::star::util::XCancellable * >( this ));
134cdf0e10cSrcweir if ( !aIface.hasValue() )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
137cdf0e10cSrcweir if ( ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) == rType && xGRes.is() )
138cdf0e10cSrcweir aIface = ::cppu::queryInterface(rType,static_cast< XGeneratedResultSet * >( this ));
139cdf0e10cSrcweir } // if ( !aIface.hasValue() )
140cdf0e10cSrcweir if ( !aIface.hasValue() )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir Reference< XPreparedBatchExecution > xGRes(m_xAggregateAsSet, UNO_QUERY);
143cdf0e10cSrcweir if ( ::getCppuType( (const Reference< XPreparedBatchExecution > *)0 ) == rType && xGRes.is() )
144cdf0e10cSrcweir aIface = ::cppu::queryInterface(rType,static_cast< XPreparedBatchExecution * >( this ));
145cdf0e10cSrcweir }
146cdf0e10cSrcweir }
147cdf0e10cSrcweir return aIface;
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir //--------------------------------------------------------------------------
acquire()151cdf0e10cSrcweir void OStatementBase::acquire() throw ()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir OSubComponent::acquire();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //--------------------------------------------------------------------------
release()157cdf0e10cSrcweir void OStatementBase::release() throw ()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir OSubComponent::release();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir //------------------------------------------------------------------------------
disposeResultSet()163cdf0e10cSrcweir void OStatementBase::disposeResultSet()
164cdf0e10cSrcweir {
165cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::disposeResultSet" );
166cdf0e10cSrcweir // free the cursor if alive
167cdf0e10cSrcweir Reference< XComponent > xComp(m_aResultSet.get(), UNO_QUERY);
168cdf0e10cSrcweir if (xComp.is())
169cdf0e10cSrcweir xComp->dispose();
170cdf0e10cSrcweir m_aResultSet = NULL;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir // OComponentHelper
174cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing()175cdf0e10cSrcweir void OStatementBase::disposing()
176cdf0e10cSrcweir {
177cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::disposing" );
178cdf0e10cSrcweir OPropertySetHelper::disposing();
179cdf0e10cSrcweir
180cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
181cdf0e10cSrcweir
182cdf0e10cSrcweir // free pending results
183cdf0e10cSrcweir disposeResultSet();
184cdf0e10cSrcweir
185cdf0e10cSrcweir // free the original statement
186cdf0e10cSrcweir {
187cdf0e10cSrcweir MutexGuard aCancelGuard(m_aCancelMutex);
188cdf0e10cSrcweir m_xAggregateAsCancellable = NULL;
189cdf0e10cSrcweir }
190cdf0e10cSrcweir
191cdf0e10cSrcweir if ( m_xAggregateAsSet.is() )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir try
194cdf0e10cSrcweir {
195cdf0e10cSrcweir Reference< XCloseable > (m_xAggregateAsSet, UNO_QUERY)->close();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir catch(RuntimeException& )
198cdf0e10cSrcweir {// don't care for anymore
199cdf0e10cSrcweir }
200cdf0e10cSrcweir }
201cdf0e10cSrcweir m_xAggregateAsSet = NULL;
202cdf0e10cSrcweir
203cdf0e10cSrcweir // free the parent at last
204cdf0e10cSrcweir OSubComponent::disposing();
205cdf0e10cSrcweir }
206cdf0e10cSrcweir
207cdf0e10cSrcweir // XCloseable
208cdf0e10cSrcweir //------------------------------------------------------------------------------
close(void)209cdf0e10cSrcweir void OStatementBase::close(void) throw( SQLException, RuntimeException )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::close" );
212cdf0e10cSrcweir {
213cdf0e10cSrcweir MutexGuard aGuard( m_aMutex );
214cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
215cdf0e10cSrcweir }
216cdf0e10cSrcweir dispose();
217cdf0e10cSrcweir }
218cdf0e10cSrcweir
219cdf0e10cSrcweir // OPropertySetHelper
220cdf0e10cSrcweir //------------------------------------------------------------------------------
getPropertySetInfo()221cdf0e10cSrcweir Reference< XPropertySetInfo > OStatementBase::getPropertySetInfo() throw (RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getPropertySetInfo" );
224cdf0e10cSrcweir return createPropertySetInfo( getInfoHelper() ) ;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir // comphelper::OPropertyArrayUsageHelper
228cdf0e10cSrcweir //------------------------------------------------------------------------------
createArrayHelper() const229cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OStatementBase::createArrayHelper( ) const
230cdf0e10cSrcweir {
231cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::createArrayHelper" );
232cdf0e10cSrcweir BEGIN_PROPERTY_HELPER(10)
233cdf0e10cSrcweir DECL_PROP0(CURSORNAME, ::rtl::OUString);
234cdf0e10cSrcweir DECL_PROP0_BOOL(ESCAPE_PROCESSING);
235cdf0e10cSrcweir DECL_PROP0(FETCHDIRECTION, sal_Int32);
236cdf0e10cSrcweir DECL_PROP0(FETCHSIZE, sal_Int32);
237cdf0e10cSrcweir DECL_PROP0(MAXFIELDSIZE, sal_Int32);
238cdf0e10cSrcweir DECL_PROP0(MAXROWS, sal_Int32);
239cdf0e10cSrcweir DECL_PROP0(QUERYTIMEOUT, sal_Int32);
240cdf0e10cSrcweir DECL_PROP0(RESULTSETCONCURRENCY, sal_Int32);
241cdf0e10cSrcweir DECL_PROP0(RESULTSETTYPE, sal_Int32);
242cdf0e10cSrcweir DECL_PROP0_BOOL(USEBOOKMARKS);
243cdf0e10cSrcweir END_PROPERTY_HELPER();
244cdf0e10cSrcweir }
245cdf0e10cSrcweir
246cdf0e10cSrcweir // cppu::OPropertySetHelper
247cdf0e10cSrcweir //------------------------------------------------------------------------------
getInfoHelper()248cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& OStatementBase::getInfoHelper()
249cdf0e10cSrcweir {
250cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getInfoHelper" );
251cdf0e10cSrcweir return *getArrayHelper();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir //------------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)255cdf0e10cSrcweir sal_Bool OStatementBase::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::convertFastPropertyValue" );
258cdf0e10cSrcweir sal_Bool bModified(sal_False);
259cdf0e10cSrcweir switch (nHandle)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir case PROPERTY_ID_USEBOOKMARKS:
262cdf0e10cSrcweir bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, m_bUseBookmarks );
263cdf0e10cSrcweir break;
264cdf0e10cSrcweir
265cdf0e10cSrcweir case PROPERTY_ID_ESCAPE_PROCESSING:
266cdf0e10cSrcweir bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, m_bEscapeProcessing );
267cdf0e10cSrcweir break;
268cdf0e10cSrcweir
269cdf0e10cSrcweir default:
270cdf0e10cSrcweir if ( m_xAggregateAsSet.is() )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir // get the property name
273cdf0e10cSrcweir ::rtl::OUString sPropName;
274cdf0e10cSrcweir getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
275cdf0e10cSrcweir
276cdf0e10cSrcweir // now set the value
277cdf0e10cSrcweir Any aCurrentValue = m_xAggregateAsSet->getPropertyValue( sPropName );
278cdf0e10cSrcweir if ( aCurrentValue != rValue )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir rOldValue = aCurrentValue;
281cdf0e10cSrcweir rConvertedValue = rValue;
282cdf0e10cSrcweir bModified = sal_True;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir }
285cdf0e10cSrcweir break;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir return bModified;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir //------------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)291cdf0e10cSrcweir void OStatementBase::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
292cdf0e10cSrcweir {
293cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::setFastPropertyValue_NoBroadcast" );
294cdf0e10cSrcweir switch ( nHandle )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir case PROPERTY_ID_USEBOOKMARKS:
297cdf0e10cSrcweir {
298cdf0e10cSrcweir m_bUseBookmarks = ::comphelper::getBOOL( rValue );
299cdf0e10cSrcweir if ( m_xAggregateAsSet.is() && m_xAggregateAsSet->getPropertySetInfo()->hasPropertyByName( PROPERTY_USEBOOKMARKS ) )
300cdf0e10cSrcweir m_xAggregateAsSet->setPropertyValue( PROPERTY_USEBOOKMARKS, rValue );
301cdf0e10cSrcweir }
302cdf0e10cSrcweir break;
303cdf0e10cSrcweir
304cdf0e10cSrcweir case PROPERTY_ID_ESCAPE_PROCESSING:
305cdf0e10cSrcweir m_bEscapeProcessing = ::comphelper::getBOOL( rValue );
306cdf0e10cSrcweir if ( m_xAggregateAsSet.is() )
307cdf0e10cSrcweir m_xAggregateAsSet->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, rValue );
308cdf0e10cSrcweir break;
309cdf0e10cSrcweir
310cdf0e10cSrcweir default:
311cdf0e10cSrcweir if ( m_xAggregateAsSet.is() )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir ::rtl::OUString sPropName;
314cdf0e10cSrcweir getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
315cdf0e10cSrcweir m_xAggregateAsSet->setPropertyValue( sPropName, rValue );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir break;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir }
320cdf0e10cSrcweir
321cdf0e10cSrcweir //------------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const322cdf0e10cSrcweir void OStatementBase::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
323cdf0e10cSrcweir {
324cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getFastPropertyValue" );
325cdf0e10cSrcweir switch (nHandle)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir case PROPERTY_ID_USEBOOKMARKS:
328cdf0e10cSrcweir rValue <<= m_bUseBookmarks;
329cdf0e10cSrcweir break;
330cdf0e10cSrcweir
331cdf0e10cSrcweir case PROPERTY_ID_ESCAPE_PROCESSING:
332cdf0e10cSrcweir // don't rely on our aggregate - if it implements this wrong, and always returns
333cdf0e10cSrcweir // TRUE here, then we would loop in impl_doEscapeProcessing_nothrow
334cdf0e10cSrcweir rValue <<= m_bEscapeProcessing;
335cdf0e10cSrcweir break;
336cdf0e10cSrcweir
337cdf0e10cSrcweir default:
338cdf0e10cSrcweir if ( m_xAggregateAsSet.is() )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir ::rtl::OUString sPropName;
341cdf0e10cSrcweir const_cast< OStatementBase* >( this )->getInfoHelper().fillPropertyMembersByHandle( &sPropName, NULL, nHandle );
342cdf0e10cSrcweir rValue = m_xAggregateAsSet->getPropertyValue( sPropName );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir break;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir // XWarningsSupplier
349cdf0e10cSrcweir //------------------------------------------------------------------------------
getWarnings(void)350cdf0e10cSrcweir Any OStatementBase::getWarnings(void) throw( SQLException, RuntimeException )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getWarnings" );
353cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
354cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
355cdf0e10cSrcweir
356cdf0e10cSrcweir return Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->getWarnings();
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir //------------------------------------------------------------------------------
clearWarnings(void)360cdf0e10cSrcweir void OStatementBase::clearWarnings(void) throw( SQLException, RuntimeException )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::clearWarnings" );
363cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
364cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
365cdf0e10cSrcweir
366cdf0e10cSrcweir Reference< XWarningsSupplier >(m_xAggregateAsSet, UNO_QUERY)->clearWarnings();
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir // ::com::sun::star::util::XCancellable
370cdf0e10cSrcweir //------------------------------------------------------------------------------
cancel(void)371cdf0e10cSrcweir void OStatementBase::cancel(void) throw( RuntimeException )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::cancel" );
374cdf0e10cSrcweir // no blocking as cancel is typically called from a different thread
375cdf0e10cSrcweir ClearableMutexGuard aCancelGuard(m_aCancelMutex);
376cdf0e10cSrcweir if (m_xAggregateAsCancellable.is())
377cdf0e10cSrcweir m_xAggregateAsCancellable->cancel();
378cdf0e10cSrcweir // else do nothing
379cdf0e10cSrcweir }
380cdf0e10cSrcweir
381cdf0e10cSrcweir // XMultipleResults
382cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSet()383cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OStatementBase::getResultSet( ) throw(SQLException, RuntimeException)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getResultSet" );
386cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
387cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
388cdf0e10cSrcweir
389cdf0e10cSrcweir // first check the meta data
390cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
391cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
392cdf0e10cSrcweir throwFunctionSequenceException(*this);
393cdf0e10cSrcweir
394cdf0e10cSrcweir return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getResultSet();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir //------------------------------------------------------------------------------
getUpdateCount()398cdf0e10cSrcweir sal_Int32 SAL_CALL OStatementBase::getUpdateCount( ) throw(SQLException, RuntimeException)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getUpdateCount" );
401cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
402cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
403cdf0e10cSrcweir
404cdf0e10cSrcweir // first check the meta data
405cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
406cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
407cdf0e10cSrcweir throwFunctionSequenceException(*this);
408cdf0e10cSrcweir
409cdf0e10cSrcweir return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getUpdateCount();
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir //------------------------------------------------------------------------------
getMoreResults()413cdf0e10cSrcweir sal_Bool SAL_CALL OStatementBase::getMoreResults( ) throw(SQLException, RuntimeException)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getMoreResults" );
416cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
417cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
418cdf0e10cSrcweir
419cdf0e10cSrcweir // first check the meta data
420cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
421cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsMultipleResultSets())
422cdf0e10cSrcweir throwFunctionSequenceException(*this);
423cdf0e10cSrcweir throwFunctionSequenceException(*this);
424cdf0e10cSrcweir
425cdf0e10cSrcweir // free the previous results
426cdf0e10cSrcweir disposeResultSet();
427cdf0e10cSrcweir
428cdf0e10cSrcweir return Reference< XMultipleResults >(m_xAggregateAsSet, UNO_QUERY)->getMoreResults();
429cdf0e10cSrcweir }
430cdf0e10cSrcweir
431cdf0e10cSrcweir // XPreparedBatchExecution
432cdf0e10cSrcweir //------------------------------------------------------------------------------
addBatch()433cdf0e10cSrcweir void SAL_CALL OStatementBase::addBatch( ) throw(SQLException, RuntimeException)
434cdf0e10cSrcweir {
435cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::addBatch" );
436cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
437cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
438cdf0e10cSrcweir
439cdf0e10cSrcweir // first check the meta data
440cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
441cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
442cdf0e10cSrcweir throwFunctionSequenceException(*this);
443cdf0e10cSrcweir
444cdf0e10cSrcweir Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch();
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
447cdf0e10cSrcweir //------------------------------------------------------------------------------
clearBatch()448cdf0e10cSrcweir void SAL_CALL OStatementBase::clearBatch( ) throw(SQLException, RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::clearBatch" );
451cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
452cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
453cdf0e10cSrcweir
454cdf0e10cSrcweir // first check the meta data
455cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
456cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
457cdf0e10cSrcweir throwFunctionSequenceException(*this);
458cdf0e10cSrcweir
459cdf0e10cSrcweir Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
460cdf0e10cSrcweir }
461cdf0e10cSrcweir
462cdf0e10cSrcweir //------------------------------------------------------------------------------
executeBatch()463cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL OStatementBase::executeBatch( ) throw(SQLException, RuntimeException)
464cdf0e10cSrcweir {
465cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::executeBatch" );
466cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
467cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
468cdf0e10cSrcweir
469cdf0e10cSrcweir // first check the meta data
470cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
471cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
472cdf0e10cSrcweir throwFunctionSequenceException(*this);
473cdf0e10cSrcweir
474cdf0e10cSrcweir // free the previous results
475cdf0e10cSrcweir disposeResultSet();
476cdf0e10cSrcweir
477cdf0e10cSrcweir return Reference< XPreparedBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch();
478cdf0e10cSrcweir }
479cdf0e10cSrcweir // -----------------------------------------------------------------------------
getGeneratedValues()480cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OStatementBase::getGeneratedValues( ) throw (SQLException, RuntimeException)
481cdf0e10cSrcweir {
482cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatementBase::getGeneratedValues" );
483cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
484cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
485cdf0e10cSrcweir Reference< XGeneratedResultSet > xGRes(m_xAggregateAsSet, UNO_QUERY);
486cdf0e10cSrcweir
487cdf0e10cSrcweir if ( xGRes.is() )
488cdf0e10cSrcweir return xGRes->getGeneratedValues( );
489cdf0e10cSrcweir return Reference< XResultSet >();
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
492cdf0e10cSrcweir //************************************************************
493cdf0e10cSrcweir // OStatement
494cdf0e10cSrcweir //************************************************************
495cdf0e10cSrcweir //------------------------------------------------------------------------------
OStatement(const Reference<XConnection> & _xConn,const Reference<XInterface> & _xStatement)496cdf0e10cSrcweir OStatement::OStatement( const Reference< XConnection >& _xConn, const Reference< XInterface > & _xStatement )
497cdf0e10cSrcweir :OStatementBase( _xConn, _xStatement )
498cdf0e10cSrcweir ,m_bAttemptedComposerCreation( false )
499cdf0e10cSrcweir {
500cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::OStatement" );
501cdf0e10cSrcweir m_xAggregateStatement.set( _xStatement, UNO_QUERY_THROW );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir
504cdf0e10cSrcweir //------------------------------------------------------------------------------
505cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OStatement, OStatementBase, OStatement_IFACE );
506cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( OStatement, OStatementBase, OStatement_IFACE );
507cdf0e10cSrcweir
508cdf0e10cSrcweir // XServiceInfo
509cdf0e10cSrcweir //------------------------------------------------------------------------------
getImplementationName()510cdf0e10cSrcweir rtl::OUString OStatement::getImplementationName( ) throw(RuntimeException)
511cdf0e10cSrcweir {
512cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getImplementationName" );
513cdf0e10cSrcweir return rtl::OUString::createFromAscii("com.sun.star.sdb.OStatement");
514cdf0e10cSrcweir }
515cdf0e10cSrcweir
516cdf0e10cSrcweir //------------------------------------------------------------------------------
supportsService(const::rtl::OUString & _rServiceName)517cdf0e10cSrcweir sal_Bool OStatement::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
518cdf0e10cSrcweir {
519cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::supportsService" );
520cdf0e10cSrcweir return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir
523cdf0e10cSrcweir //------------------------------------------------------------------------------
getSupportedServiceNames()524cdf0e10cSrcweir Sequence< ::rtl::OUString > OStatement::getSupportedServiceNames( ) throw (RuntimeException)
525cdf0e10cSrcweir {
526cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getSupportedServiceNames" );
527cdf0e10cSrcweir Sequence< ::rtl::OUString > aSNS( 1 );
528cdf0e10cSrcweir aSNS.getArray()[0] = SERVICE_SDBC_STATEMENT;
529cdf0e10cSrcweir return aSNS;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir
532cdf0e10cSrcweir // XStatement
533cdf0e10cSrcweir //------------------------------------------------------------------------------
executeQuery(const rtl::OUString & _rSQL)534cdf0e10cSrcweir Reference< XResultSet > OStatement::executeQuery( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::executeQuery" );
537cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
538cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
539cdf0e10cSrcweir
540cdf0e10cSrcweir disposeResultSet();
541cdf0e10cSrcweir Reference< XResultSet > xResultSet;
542cdf0e10cSrcweir
543cdf0e10cSrcweir ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
544cdf0e10cSrcweir
545cdf0e10cSrcweir Reference< XResultSet > xInnerResultSet = m_xAggregateStatement->executeQuery( sSQL );
546cdf0e10cSrcweir Reference< XConnection > xConnection( m_xParent, UNO_QUERY_THROW );
547cdf0e10cSrcweir
548cdf0e10cSrcweir if ( xInnerResultSet.is() )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
551cdf0e10cSrcweir sal_Bool bCaseSensitive = xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers();
552cdf0e10cSrcweir xResultSet = new OResultSet( xInnerResultSet, *this, bCaseSensitive );
553cdf0e10cSrcweir
554cdf0e10cSrcweir // keep the resultset weak
555cdf0e10cSrcweir m_aResultSet = xResultSet;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir
558cdf0e10cSrcweir return xResultSet;
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir //------------------------------------------------------------------------------
executeUpdate(const rtl::OUString & _rSQL)562cdf0e10cSrcweir sal_Int32 OStatement::executeUpdate( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::executeUpdate" );
565cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
566cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
567cdf0e10cSrcweir
568cdf0e10cSrcweir disposeResultSet();
569cdf0e10cSrcweir
570cdf0e10cSrcweir ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
571cdf0e10cSrcweir return m_xAggregateStatement->executeUpdate( sSQL );
572cdf0e10cSrcweir }
573cdf0e10cSrcweir
574cdf0e10cSrcweir //------------------------------------------------------------------------------
execute(const rtl::OUString & _rSQL)575cdf0e10cSrcweir sal_Bool OStatement::execute( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
576cdf0e10cSrcweir {
577cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
578cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
579cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
580cdf0e10cSrcweir
581cdf0e10cSrcweir disposeResultSet();
582cdf0e10cSrcweir
583cdf0e10cSrcweir ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
584cdf0e10cSrcweir return m_xAggregateStatement->execute( sSQL );
585cdf0e10cSrcweir }
586cdf0e10cSrcweir //------------------------------------------------------------------------------
addBatch(const rtl::OUString & _rSQL)587cdf0e10cSrcweir void OStatement::addBatch( const rtl::OUString& _rSQL ) throw( SQLException, RuntimeException )
588cdf0e10cSrcweir {
589cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
590cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
591cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
592cdf0e10cSrcweir
593cdf0e10cSrcweir // first check the meta data
594cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
595cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
596cdf0e10cSrcweir throwFunctionSequenceException(*this);
597cdf0e10cSrcweir
598cdf0e10cSrcweir ::rtl::OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) );
599cdf0e10cSrcweir Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->addBatch( sSQL );
600cdf0e10cSrcweir }
601cdf0e10cSrcweir //------------------------------------------------------------------------------
clearBatch()602cdf0e10cSrcweir void OStatement::clearBatch( ) throw( SQLException, RuntimeException )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
605cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
606cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
607cdf0e10cSrcweir // first check the meta data
608cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
609cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
610cdf0e10cSrcweir throwFunctionSequenceException(*this);
611cdf0e10cSrcweir
612cdf0e10cSrcweir Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->clearBatch();
613cdf0e10cSrcweir }
614cdf0e10cSrcweir //------------------------------------------------------------------------------
executeBatch()615cdf0e10cSrcweir Sequence< sal_Int32 > OStatement::executeBatch( ) throw( SQLException, RuntimeException )
616cdf0e10cSrcweir {
617cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::execute" );
618cdf0e10cSrcweir MutexGuard aGuard(m_aMutex);
619cdf0e10cSrcweir ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
620cdf0e10cSrcweir // first check the meta data
621cdf0e10cSrcweir Reference<XDatabaseMetaData> xMeta = Reference< XConnection > (m_xParent, UNO_QUERY)->getMetaData();
622cdf0e10cSrcweir if (!xMeta.is() && !xMeta->supportsBatchUpdates())
623cdf0e10cSrcweir throwFunctionSequenceException(*this);
624cdf0e10cSrcweir return Reference< XBatchExecution >(m_xAggregateAsSet, UNO_QUERY)->executeBatch( );
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
627cdf0e10cSrcweir //------------------------------------------------------------------------------
getConnection(void)628cdf0e10cSrcweir Reference< XConnection > OStatement::getConnection(void) throw( SQLException, RuntimeException )
629cdf0e10cSrcweir {
630cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::getConnection" );
631cdf0e10cSrcweir return Reference< XConnection >( m_xParent, UNO_QUERY );
632cdf0e10cSrcweir }
633cdf0e10cSrcweir
634cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing()635cdf0e10cSrcweir void SAL_CALL OStatement::disposing()
636cdf0e10cSrcweir {
637cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::disposing" );
638cdf0e10cSrcweir OStatementBase::disposing();
639cdf0e10cSrcweir m_xComposer.clear();
640cdf0e10cSrcweir m_xAggregateStatement.clear();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
643cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_doEscapeProcessing_nothrow(const::rtl::OUString & _rSQL) const644cdf0e10cSrcweir ::rtl::OUString OStatement::impl_doEscapeProcessing_nothrow( const ::rtl::OUString& _rSQL ) const
645cdf0e10cSrcweir {
646cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::impl_doEscapeProcessing_nothrow" );
647cdf0e10cSrcweir if ( !m_bEscapeProcessing )
648cdf0e10cSrcweir return _rSQL;
649cdf0e10cSrcweir try
650cdf0e10cSrcweir {
651cdf0e10cSrcweir if ( !impl_ensureComposer_nothrow() )
652cdf0e10cSrcweir return _rSQL;
653cdf0e10cSrcweir
654cdf0e10cSrcweir bool bParseable = false;
655cdf0e10cSrcweir try { m_xComposer->setQuery( _rSQL ); bParseable = true; }
656cdf0e10cSrcweir catch( const SQLException& ) { }
657cdf0e10cSrcweir
658cdf0e10cSrcweir if ( !bParseable )
659cdf0e10cSrcweir // if we cannot parse it, silently accept this. The driver is probably able to cope with it then
660cdf0e10cSrcweir return _rSQL;
661cdf0e10cSrcweir
662cdf0e10cSrcweir ::rtl::OUString sLowLevelSQL = m_xComposer->getQueryWithSubstitution();
663cdf0e10cSrcweir return sLowLevelSQL;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir catch( const Exception& )
666cdf0e10cSrcweir {
667cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
670cdf0e10cSrcweir return _rSQL;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir
673cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_ensureComposer_nothrow() const674cdf0e10cSrcweir bool OStatement::impl_ensureComposer_nothrow() const
675cdf0e10cSrcweir {
676cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OStatement::impl_ensureComposer_nothrow" );
677cdf0e10cSrcweir if ( m_bAttemptedComposerCreation )
678cdf0e10cSrcweir return m_xComposer.is();
679cdf0e10cSrcweir
680cdf0e10cSrcweir const_cast< OStatement* >( this )->m_bAttemptedComposerCreation = true;
681cdf0e10cSrcweir try
682cdf0e10cSrcweir {
683cdf0e10cSrcweir Reference< XMultiServiceFactory > xFactory( m_xParent, UNO_QUERY_THROW );
684cdf0e10cSrcweir const_cast< OStatement* >( this )->m_xComposer.set( xFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW );
685cdf0e10cSrcweir }
686cdf0e10cSrcweir catch( const Exception& )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir
691cdf0e10cSrcweir return m_xComposer.is();
692cdf0e10cSrcweir }
693