2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-12 22:04:38 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-17 01:15:32 +00:00
|
|
|
|
2017-10-27 19:27:55 +02:00
|
|
|
#include <ado/AStatement.hxx>
|
|
|
|
#include <ado/AConnection.hxx>
|
|
|
|
#include <ado/AResultSet.hxx>
|
2000-10-09 10:26:03 +00:00
|
|
|
#include <comphelper/property.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <osl/thread.h>
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2014-11-18 00:06:30 +01:00
|
|
|
#include <cppuhelper/queryinterface.hxx>
|
2000-10-09 10:26:03 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
|
|
|
|
#include <com/sun/star/sdbc/ResultSetType.hpp>
|
|
|
|
#include <com/sun/star/sdbc/FetchDirection.hpp>
|
2014-06-04 15:29:58 +02:00
|
|
|
#include <connectivity/dbexception.hxx>
|
2001-05-18 07:51:34 +00:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
|
2008-06-24 14:59:34 +00:00
|
|
|
#undef max
|
|
|
|
|
2001-10-12 14:01:36 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2001-05-18 07:51:34 +00:00
|
|
|
using namespace ::comphelper;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
#define CHECK_RETURN(x) \
|
|
|
|
if(!x) \
|
|
|
|
ADOS::ThrowException(*m_pConnection->getConnection(),*this);
|
|
|
|
|
2000-10-24 15:14:04 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
using namespace connectivity::ado;
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace com::sun::star::sdbc;
|
2008-06-06 12:19:59 +00:00
|
|
|
using namespace ::std;
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex)
|
|
|
|
,OPropertySetHelper(OStatement_BASE::rBHelper)
|
|
|
|
,m_pConnection(_pConnection)
|
|
|
|
,m_nMaxRows(0)
|
2012-03-10 18:34:00 +01:00
|
|
|
,m_nFetchSize(1)
|
2000-09-18 15:18:56 +00:00
|
|
|
,m_eLockType(adLockReadOnly)
|
|
|
|
,m_eCursorType(adOpenForwardOnly)
|
|
|
|
{
|
2012-09-22 01:51:12 -05:00
|
|
|
osl_atomic_increment( &m_refCount );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_Command.Create();
|
|
|
|
if(m_Command.IsValid())
|
|
|
|
m_Command.putref_ActiveConnection(m_pConnection->getConnection());
|
|
|
|
else
|
|
|
|
ADOS::ThrowException(*m_pConnection->getConnection(),*this);
|
|
|
|
|
|
|
|
m_RecordsAffected.setNoArg();
|
|
|
|
m_Parameters.setNoArg();
|
|
|
|
|
|
|
|
m_pConnection->acquire();
|
|
|
|
|
2012-09-22 01:51:12 -05:00
|
|
|
osl_atomic_decrement( &m_refCount );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
void OStatement_Base::disposeResultSet()
|
|
|
|
{
|
|
|
|
// free the cursor if alive
|
|
|
|
Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
|
|
|
|
if (xComp.is())
|
|
|
|
xComp->dispose();
|
2013-06-04 17:16:58 +02:00
|
|
|
m_xResultSet.clear();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
void OStatement_Base::disposing()
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
|
|
|
|
disposeResultSet();
|
|
|
|
|
2002-01-18 15:35:28 +00:00
|
|
|
if ( m_Command.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
m_Command.putref_ActiveConnection( nullptr );
|
2000-09-18 15:18:56 +00:00
|
|
|
m_Command.clear();
|
2002-01-18 15:35:28 +00:00
|
|
|
|
|
|
|
if ( m_RecordSet.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
m_RecordSet.PutRefDataSource( nullptr );
|
2000-09-18 15:18:56 +00:00
|
|
|
m_RecordSet.clear();
|
|
|
|
|
|
|
|
if (m_pConnection)
|
|
|
|
m_pConnection->release();
|
|
|
|
|
|
|
|
OStatement_BASE::disposing();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2007-03-26 12:58:00 +00:00
|
|
|
void SAL_CALL OStatement_Base::release() throw()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2018-02-01 13:54:31 +02:00
|
|
|
OStatement_BASE::release();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL OStatement_Base::queryInterface( const Type & rType )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Any aRet = OStatement_BASE::queryInterface(rType);
|
2001-08-24 05:19:41 +00:00
|
|
|
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
css::uno::Sequence< css::uno::Type > SAL_CALL OStatement_Base::getTypes( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2016-05-27 12:31:29 +02:00
|
|
|
::cppu::OTypeCollection aTypes( cppu::UnoType<css::beans::XMultiPropertySet>::get(),
|
|
|
|
cppu::UnoType<css::beans::XFastPropertySet>::get(),
|
|
|
|
cppu::UnoType<css::beans::XPropertySet>::get());
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-10-09 10:26:03 +00:00
|
|
|
return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL OStatement_Base::cancel( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
CHECK_RETURN(m_Command.Cancel())
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL OStatement_Base::close( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
dispose();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL OStatement::clearBatch( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::reset()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
clearWarnings ();
|
|
|
|
|
|
|
|
if (m_xResultSet.get().is())
|
|
|
|
clearMyResultSet();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// clearMyResultSet
|
|
|
|
// If a ResultSet was created for this Statement, close it
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::clearMyResultSet ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2006-07-26 06:22:13 +00:00
|
|
|
try
|
|
|
|
{
|
2015-04-21 08:56:05 +02:00
|
|
|
Reference<XCloseable> xCloseable(
|
|
|
|
m_xResultSet.get(), css::uno::UNO_QUERY);
|
|
|
|
if ( xCloseable.is() )
|
2006-07-26 06:22:13 +00:00
|
|
|
xCloseable->close();
|
|
|
|
}
|
|
|
|
catch( const DisposedException& ) { }
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2013-06-04 17:16:58 +02:00
|
|
|
m_xResultSet.clear();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getRowCount ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-10-11 18:16:52 +02:00
|
|
|
return m_RecordsAffected.getInt32();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// getPrecision
|
|
|
|
// Given a SQL type, return the maximum precision for the column.
|
|
|
|
// Returns -1 if not known
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
sal_Int32 prec = -1;
|
|
|
|
OTypeInfo aInfo;
|
2018-01-22 13:11:34 +01:00
|
|
|
aInfo.nType = static_cast<sal_Int16>(sqlType);
|
2008-06-06 12:19:59 +00:00
|
|
|
if (!m_aTypeInfo.empty())
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2017-02-15 23:55:18 +02:00
|
|
|
std::vector<OTypeInfo>::const_iterator aIter = std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
|
2000-09-18 15:18:56 +00:00
|
|
|
for(;aIter != m_aTypeInfo.end();++aIter)
|
|
|
|
{
|
2017-02-15 23:55:18 +02:00
|
|
|
prec = std::max(prec,(*aIter).nPrecision);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return prec;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// setWarning
|
|
|
|
// Sets the warning
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setWarning (const SQLWarning &ex)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_aLastWarning = ex;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2002-01-18 15:35:28 +00:00
|
|
|
void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
|
|
|
|
{
|
|
|
|
WpADORecordset aOldRS( m_RecordSet );
|
|
|
|
m_RecordSet = WpADORecordset( _pRS );
|
|
|
|
|
|
|
|
if ( aOldRS.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
aOldRS.PutRefDataSource( nullptr );
|
2002-01-18 15:35:28 +00:00
|
|
|
|
|
|
|
if ( m_RecordSet.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
m_RecordSet.PutRefDataSource( static_cast<IDispatch*>(m_Command) );
|
2002-01-18 15:35:28 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Bool SAL_CALL OStatement_Base::execute( const OUString& sql )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Reset the statement handle and warning
|
|
|
|
|
|
|
|
reset();
|
|
|
|
|
2002-01-18 15:35:28 +00:00
|
|
|
try
|
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
ADORecordset* pSet = nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
CHECK_RETURN(m_Command.put_CommandText(sql))
|
|
|
|
CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet))
|
2002-01-18 15:35:28 +00:00
|
|
|
|
|
|
|
assignRecordSet( pSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2002-01-18 15:35:28 +00:00
|
|
|
catch (SQLWarning& ex)
|
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Save pointer to warning and save with ResultSet
|
|
|
|
// object once it is created.
|
|
|
|
|
|
|
|
m_aLastWarning = ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_RecordSet.IsValid();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const OUString& sql )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
reset();
|
|
|
|
|
2016-10-14 16:57:58 +02:00
|
|
|
m_xResultSet = WeakReference<XResultSet>(nullptr);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
WpADORecordset aSet;
|
|
|
|
aSet.Create();
|
|
|
|
CHECK_RETURN(m_Command.put_CommandText(sql))
|
|
|
|
OLEVariant aCmd;
|
|
|
|
aCmd.setIDispatch(m_Command);
|
|
|
|
OLEVariant aCon;
|
|
|
|
aCon.setNoArg();
|
|
|
|
CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize))
|
|
|
|
CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows))
|
|
|
|
CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
|
|
|
|
|
|
|
|
|
|
|
|
CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize))
|
|
|
|
CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows))
|
|
|
|
CHECK_RETURN(aSet.get_CursorType(m_eCursorType))
|
|
|
|
CHECK_RETURN(aSet.get_LockType(m_eLockType))
|
|
|
|
|
|
|
|
OResultSet* pSet = new OResultSet(aSet,this);
|
2005-12-21 12:15:37 +00:00
|
|
|
Reference< XResultSet > xRs = pSet;
|
|
|
|
pSet->construct();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2005-12-21 12:15:37 +00:00
|
|
|
m_xResultSet = WeakReference<XResultSet>(xRs);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2005-12-21 12:15:37 +00:00
|
|
|
return xRs;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Reference< XConnection > SAL_CALL OStatement_Base::getConnection( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2016-10-14 16:57:58 +02:00
|
|
|
return static_cast<Reference< XConnection >>(m_pConnection);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL OStatement::queryInterface( const Type & rType )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
|
2001-08-24 05:19:41 +00:00
|
|
|
return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL OStatement::addBatch( const OUString& sql )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-08-31 20:32:58 +02:00
|
|
|
m_aBatchVector.push_back(sql);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
reset();
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aBatchSql;
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Int32 nLen = 0;
|
2017-08-31 20:32:58 +02:00
|
|
|
for(std::vector< OUString>::const_iterator i=m_aBatchVector.begin();i != m_aBatchVector.end();++i,++nLen)
|
2013-12-13 09:29:22 +02:00
|
|
|
aBatchSql = aBatchSql + *i + ";";
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2002-01-18 15:35:28 +00:00
|
|
|
|
|
|
|
if ( m_RecordSet.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
m_RecordSet.PutRefDataSource( nullptr );
|
2000-09-18 15:18:56 +00:00
|
|
|
m_RecordSet.clear();
|
|
|
|
m_RecordSet.Create();
|
|
|
|
|
|
|
|
CHECK_RETURN(m_Command.put_CommandText(aBatchSql))
|
2002-01-18 15:35:28 +00:00
|
|
|
if ( m_RecordSet.IsValid() )
|
2016-10-14 16:57:58 +02:00
|
|
|
m_RecordSet.PutRefDataSource(static_cast<IDispatch*>(m_Command));
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
|
|
|
|
|
2016-10-14 16:57:58 +02:00
|
|
|
ADORecordset* pSet=nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
Sequence< sal_Int32 > aRet(nLen);
|
|
|
|
sal_Int32* pArray = aRet.getArray();
|
|
|
|
for(sal_Int32 j=0;j<nLen;++j)
|
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
pSet = nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
OLEVariant aRecordsAffected;
|
|
|
|
if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
|
|
|
|
{
|
2002-01-18 15:35:28 +00:00
|
|
|
assignRecordSet( pSet );
|
|
|
|
|
2011-01-25 00:57:51 +02:00
|
|
|
ADO_LONGPTR nValue;
|
2000-09-18 15:18:56 +00:00
|
|
|
if(m_RecordSet.get_RecordCount(nValue))
|
|
|
|
pArray[j] = nValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const OUString& sql )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
reset();
|
|
|
|
|
|
|
|
try {
|
2016-10-14 16:57:58 +02:00
|
|
|
ADORecordset* pSet = nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
CHECK_RETURN(m_Command.put_CommandText(sql))
|
|
|
|
CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet))
|
|
|
|
}
|
|
|
|
catch (SQLWarning& ex) {
|
|
|
|
|
|
|
|
// Save pointer to warning and save with ResultSet
|
|
|
|
// object once it is created.
|
|
|
|
|
|
|
|
m_aLastWarning = ex;
|
|
|
|
}
|
|
|
|
if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR)
|
2016-10-11 18:16:52 +02:00
|
|
|
return m_RecordsAffected.getInt32();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
return m_xResultSet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2011-01-25 00:57:51 +02:00
|
|
|
ADO_LONGPTR nRet;
|
2000-09-18 15:18:56 +00:00
|
|
|
if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
|
|
|
|
return nRet;
|
|
|
|
return -1;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Bool SAL_CALL OStatement_Base::getMoreResults( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
SQLWarning warning;
|
|
|
|
|
|
|
|
// clear previous warnings
|
|
|
|
|
|
|
|
clearWarnings ();
|
|
|
|
|
|
|
|
// Call SQLMoreResults
|
|
|
|
|
2002-01-18 15:35:28 +00:00
|
|
|
try
|
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
ADORecordset* pSet=nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
OLEVariant aRecordsAffected;
|
|
|
|
if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
|
2002-01-18 15:35:28 +00:00
|
|
|
assignRecordSet( pSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2002-01-18 15:35:28 +00:00
|
|
|
catch (SQLWarning &ex)
|
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Save pointer to warning and save with ResultSet
|
|
|
|
// object once it is created.
|
|
|
|
|
|
|
|
warning = ex;
|
|
|
|
}
|
|
|
|
return m_RecordSet.IsValid();
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL OStatement_Base::getWarnings( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
return makeAny(m_aLastWarning);
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL OStatement_Base::clearWarnings( )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_aLastWarning = SQLWarning();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getQueryTimeOut() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return m_Command.get_CommandTimeout();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getMaxRows() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-25 00:57:51 +02:00
|
|
|
ADO_LONGPTR nRet=-1;
|
2001-10-18 12:24:06 +00:00
|
|
|
if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
|
2016-10-14 16:57:58 +02:00
|
|
|
::dbtools::throwFunctionSequenceException(nullptr);
|
2000-09-18 15:18:56 +00:00
|
|
|
return nRet;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getResultSetConcurrency() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-11-05 14:06:12 +01:00
|
|
|
sal_Int32 nValue;
|
|
|
|
|
|
|
|
switch(m_eLockType)
|
|
|
|
{
|
|
|
|
case adLockReadOnly:
|
|
|
|
nValue = ResultSetConcurrency::READ_ONLY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
nValue = ResultSetConcurrency::UPDATABLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nValue;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getResultSetType() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nValue=0;
|
|
|
|
switch(m_eCursorType)
|
|
|
|
{
|
|
|
|
case adOpenUnspecified:
|
|
|
|
case adOpenForwardOnly:
|
|
|
|
nValue = ResultSetType::FORWARD_ONLY;
|
|
|
|
break;
|
|
|
|
case adOpenStatic:
|
|
|
|
case adOpenKeyset:
|
|
|
|
nValue = ResultSetType::SCROLL_INSENSITIVE;
|
|
|
|
break;
|
|
|
|
case adOpenDynamic:
|
|
|
|
nValue = ResultSetType::SCROLL_SENSITIVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nValue;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getFetchDirection()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return FetchDirection::FORWARD;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getFetchSize() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return m_nFetchSize;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
sal_Int32 OStatement_Base::getMaxFieldSize()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString OStatement_Base::getCursorName() const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return m_Command.GetName();
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setQueryTimeOut(sal_Int32 seconds)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_Command.put_CommandTimeout(seconds);
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setMaxRows(sal_Int32 _par0)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
m_nMaxRows = _par0;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
switch(_par0)
|
|
|
|
{
|
|
|
|
case ResultSetConcurrency::READ_ONLY:
|
|
|
|
m_eLockType = adLockReadOnly;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_eLockType = adLockOptimistic;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setResultSetType(sal_Int32 _par0)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
switch(_par0)
|
|
|
|
{
|
|
|
|
case ResultSetType::FORWARD_ONLY:
|
|
|
|
m_eCursorType = adOpenForwardOnly;
|
|
|
|
break;
|
|
|
|
case ResultSetType::SCROLL_INSENSITIVE:
|
|
|
|
m_eCursorType = adOpenKeyset;
|
|
|
|
break;
|
|
|
|
case ResultSetType::SCROLL_SENSITIVE:
|
|
|
|
m_eCursorType = adOpenDynamic;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
2014-07-21 10:40:45 +01:00
|
|
|
::dbtools::throwFeatureNotImplementedSQLException( "Statement::FetchDirection", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setFetchSize(sal_Int32 _par0)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_nFetchSize = _par0;
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
2014-07-21 10:40:45 +01:00
|
|
|
::dbtools::throwFeatureNotImplementedSQLException( "Statement::MaxFieldSize", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setCursorName(const OUString &_par0)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2001-05-17 06:30:42 +00:00
|
|
|
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
m_Command.put_Name(_par0);
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
|
|
|
|
{
|
2016-05-27 12:31:29 +02:00
|
|
|
Sequence< css::beans::Property > aProps(10);
|
|
|
|
css::beans::Property* pProperties = aProps.getArray();
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Int32 nPos = 0;
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),
|
2015-04-01 08:36:20 +02:00
|
|
|
PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
|
2014-05-12 22:52:25 +02:00
|
|
|
PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
|
2016-05-27 12:31:29 +02:00
|
|
|
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS),
|
2015-04-01 08:36:20 +02:00
|
|
|
PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
return new ::cppu::OPropertyArrayHelper(aProps);
|
|
|
|
}
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
|
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
return *getArrayHelper();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Bool OStatement_Base::convertFastPropertyValue(
|
|
|
|
Any & rConvertedValue,
|
|
|
|
Any & rOldValue,
|
|
|
|
sal_Int32 nHandle,
|
|
|
|
const Any& rValue )
|
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
bool bModified = false;
|
2001-12-10 13:36:23 +00:00
|
|
|
|
2016-10-14 16:57:58 +02:00
|
|
|
bool bValidAdoRS = m_RecordSet.IsValid();
|
2001-12-10 13:36:23 +00:00
|
|
|
// some of the properties below, when set, are remembered in a member, and applied in the next execute
|
|
|
|
// For these properties, the record set does not need to be valid to allow setting them.
|
|
|
|
// For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid.
|
|
|
|
|
|
|
|
try
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2001-12-10 13:36:23 +00:00
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_MAXROWS:
|
|
|
|
bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_QUERYTIMEOUT:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_MAXFIELDSIZE:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
|
|
|
bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-05 10:11:05 +02:00
|
|
|
catch( const Exception& )
|
2001-12-10 13:36:23 +00:00
|
|
|
{
|
2016-10-14 16:57:58 +02:00
|
|
|
bModified = true; // will ensure that the property is set
|
2011-03-19 14:09:49 +01:00
|
|
|
OSL_FAIL( "OStatement_Base::convertFastPropertyValue: caught something strange!" );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2001-12-10 13:36:23 +00:00
|
|
|
return bModified;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_QUERYTIMEOUT:
|
2001-05-18 07:51:34 +00:00
|
|
|
setQueryTimeOut(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_MAXFIELDSIZE:
|
2001-05-18 07:51:34 +00:00
|
|
|
setMaxFieldSize(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_MAXROWS:
|
2001-05-18 07:51:34 +00:00
|
|
|
setMaxRows(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
2001-05-18 07:51:34 +00:00
|
|
|
setCursorName(comphelper::getString(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
2001-05-18 07:51:34 +00:00
|
|
|
setResultSetConcurrency(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
2001-05-18 07:51:34 +00:00
|
|
|
setResultSetType(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
2001-05-18 07:51:34 +00:00
|
|
|
setFetchDirection(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
2001-05-18 07:51:34 +00:00
|
|
|
setFetchSize(comphelper::getINT32(rValue));
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_ESCAPEPROCESSING:
|
2000-10-09 10:26:03 +00:00
|
|
|
// return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
|
2000-09-18 15:18:56 +00:00
|
|
|
case PROPERTY_ID_USEBOOKMARKS:
|
2000-10-09 10:26:03 +00:00
|
|
|
// return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
|
2000-09-18 15:18:56 +00:00
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
|
|
|
|
{
|
|
|
|
switch(nHandle)
|
|
|
|
{
|
|
|
|
case PROPERTY_ID_QUERYTIMEOUT:
|
|
|
|
rValue <<= getQueryTimeOut();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_MAXFIELDSIZE:
|
|
|
|
rValue <<= getMaxFieldSize();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_MAXROWS:
|
|
|
|
rValue <<= getMaxRows();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
|
|
|
rValue <<= getCursorName();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
|
|
|
rValue <<= getResultSetConcurrency();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
|
|
|
rValue <<= getResultSetType();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
|
|
|
rValue <<= getFetchDirection();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
|
|
|
rValue <<= getFetchSize();
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_ESCAPEPROCESSING:
|
2016-10-14 16:57:58 +02:00
|
|
|
rValue <<= true;
|
2007-11-01 13:50:04 +00:00
|
|
|
break;
|
2000-09-18 15:18:56 +00:00
|
|
|
case PROPERTY_ID_USEBOOKMARKS:
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
OStatement::~OStatement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2014-10-06 19:39:51 +02:00
|
|
|
void SAL_CALL OStatement_Base::acquire() throw()
|
|
|
|
{
|
|
|
|
OStatement_BASE::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OStatement::acquire() throw()
|
|
|
|
{
|
|
|
|
OStatement_Base::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OStatement::release() throw()
|
|
|
|
{
|
|
|
|
OStatement_Base::release();
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( )
|
2001-04-30 09:16:19 +00:00
|
|
|
{
|
|
|
|
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
|
|
|
|
}
|
2012-10-04 13:47:13 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|