Files
libreoffice/connectivity/source/drivers/ado/AStatement.cxx

833 lines
24 KiB
C++
Raw Normal View History

/* -*- 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 .
*/
#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>
#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>
#include <connectivity/dbexception.hxx>
2001-05-18 07:51:34 +00:00
#include <comphelper/types.hxx>
#undef max
#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;
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;
using namespace ::std;
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)
{
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();
osl_atomic_decrement( &m_refCount );
2000-09-18 15:18:56 +00: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();
m_xResultSet.clear();
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00:00
void OStatement_Base::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
disposeResultSet();
if ( m_Command.IsValid() )
m_Command.putref_ActiveConnection( nullptr );
2000-09-18 15:18:56 +00:00
m_Command.clear();
if ( m_RecordSet.IsValid() )
m_RecordSet.PutRefDataSource( nullptr );
2000-09-18 15:18:56 +00:00
m_RecordSet.clear();
if (m_pConnection)
m_pConnection->release();
OStatement_BASE::disposing();
}
void SAL_CALL OStatement_Base::release() throw()
2000-09-18 15:18:56 +00:00
{
OStatement_BASE::release();
2000-09-18 15:18:56 +00:00
}
Any SAL_CALL OStatement_Base::queryInterface( const Type & rType )
2000-09-18 15:18:56 +00:00
{
Any aRet = OStatement_BASE::queryInterface(rType);
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
2000-09-18 15:18:56 +00:00
}
css::uno::Sequence< css::uno::Type > SAL_CALL OStatement_Base::getTypes( )
2000-09-18 15:18:56 +00: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
}
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())
}
2000-09-18 15:18:56 +00: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();
}
2000-09-18 15:18:56 +00:00
void SAL_CALL OStatement::clearBatch( )
2000-09-18 15:18:56 +00:00
{
}
2000-09-18 15:18:56 +00: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();
}
2000-09-18 15:18:56 +00:00
// clearMyResultSet
// If a ResultSet was created for this Statement, close it
2000-09-18 15:18:56 +00: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);
try
{
Reference<XCloseable> xCloseable(
m_xResultSet.get(), css::uno::UNO_QUERY);
if ( xCloseable.is() )
xCloseable->close();
}
catch( const DisposedException& ) { }
2000-09-18 15:18:56 +00:00
m_xResultSet.clear();
2000-09-18 15:18:56 +00: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
return m_RecordsAffected.getInt32();
2000-09-18 15:18:56 +00: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
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;
aInfo.nType = static_cast<sal_Int16>(sqlType);
if (!m_aTypeInfo.empty())
2000-09-18 15:18:56 +00: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)
{
prec = std::max(prec,(*aIter).nPrecision);
2000-09-18 15:18:56 +00:00
}
}
return prec;
}
2000-09-18 15:18:56 +00:00
// setWarning
// Sets the warning
2000-09-18 15:18:56 +00: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;
}
void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
{
WpADORecordset aOldRS( m_RecordSet );
m_RecordSet = WpADORecordset( _pRS );
if ( aOldRS.IsValid() )
aOldRS.PutRefDataSource( nullptr );
if ( m_RecordSet.IsValid() )
m_RecordSet.PutRefDataSource( static_cast<IDispatch*>(m_Command) );
}
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();
try
{
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))
assignRecordSet( pSet );
2000-09-18 15:18:56 +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();
}
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();
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);
Reference< XResultSet > xRs = pSet;
pSet->construct();
2000-09-18 15:18:56 +00:00
m_xResultSet = WeakReference<XResultSet>(xRs);
2000-09-18 15:18:56 +00:00
return xRs;
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00: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
return static_cast<Reference< XConnection >>(m_pConnection);
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00: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));
return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00: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
m_aBatchVector.push_back(sql);
2000-09-18 15:18:56 +00: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();
OUString aBatchSql;
2000-09-18 15:18:56 +00:00
sal_Int32 nLen = 0;
for(std::vector< OUString>::const_iterator i=m_aBatchVector.begin();i != m_aBatchVector.end();++i,++nLen)
aBatchSql = aBatchSql + *i + ";";
2000-09-18 15:18:56 +00:00
if ( m_RecordSet.IsValid() )
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))
if ( m_RecordSet.IsValid() )
m_RecordSet.PutRefDataSource(static_cast<IDispatch*>(m_Command));
2000-09-18 15:18:56 +00:00
CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
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)
{
pSet = nullptr;
2000-09-18 15:18:56 +00:00
OLEVariant aRecordsAffected;
if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
{
assignRecordSet( pSet );
ADO_LONGPTR nValue;
2000-09-18 15:18:56 +00:00
if(m_RecordSet.get_RecordCount(nValue))
pArray[j] = nValue;
}
}
return aRet;
}
2000-09-18 15:18:56 +00: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 {
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)
return m_RecordsAffected.getInt32();
2000-09-18 15:18:56 +00:00
return 0;
}
2000-09-18 15:18:56 +00: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;
}
2000-09-18 15:18:56 +00: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
ADO_LONGPTR nRet;
2000-09-18 15:18:56 +00:00
if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
return nRet;
return -1;
}
2000-09-18 15:18:56 +00: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
try
{
ADORecordset* pSet=nullptr;
2000-09-18 15:18:56 +00:00
OLEVariant aRecordsAffected;
if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
assignRecordSet( pSet );
2000-09-18 15:18:56 +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();
}
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);
}
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();
}
sal_Int32 OStatement_Base::getQueryTimeOut() const
2000-09-18 15:18:56 +00:00
{
return m_Command.get_CommandTimeout();
}
sal_Int32 OStatement_Base::getMaxRows() const
2000-09-18 15:18:56 +00:00
{
ADO_LONGPTR nRet=-1;
2001-10-18 12:24:06 +00:00
if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
::dbtools::throwFunctionSequenceException(nullptr);
2000-09-18 15:18:56 +00:00
return nRet;
}
sal_Int32 OStatement_Base::getResultSetConcurrency() const
2000-09-18 15:18:56 +00: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
}
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;
}
sal_Int32 OStatement_Base::getFetchDirection()
2000-09-18 15:18:56 +00:00
{
return FetchDirection::FORWARD;
}
sal_Int32 OStatement_Base::getFetchSize() const
2000-09-18 15:18:56 +00:00
{
return m_nFetchSize;
}
sal_Int32 OStatement_Base::getMaxFieldSize()
2000-09-18 15:18:56 +00:00
{
return 0;
}
OUString OStatement_Base::getCursorName() const
2000-09-18 15:18:56 +00:00
{
return m_Command.GetName();
}
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);
}
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;
}
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;
}
}
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;
}
}
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);
::dbtools::throwFeatureNotImplementedSQLException( "Statement::FetchDirection", *this );
2000-09-18 15:18:56 +00: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;
}
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);
::dbtools::throwFeatureNotImplementedSQLException( "Statement::MaxFieldSize", *this );
2000-09-18 15:18:56 +00: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);
}
2000-09-18 15:18:56 +00:00
::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
{
Sequence< css::beans::Property > aProps(10);
css::beans::Property* pProperties = aProps.getArray();
2000-09-18 15:18:56 +00:00
sal_Int32 nPos = 0;
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
PROPERTY_ID_CURSORNAME, cppu::UnoType<OUString>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),
PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE),
PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS),
PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT),
PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = css::beans::Property(::connectivity::OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS),
PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0);
2000-09-18 15:18:56 +00:00
return new ::cppu::OPropertyArrayHelper(aProps);
}
2000-09-18 15:18:56 +00:00
::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
{
return *getArrayHelper();
2000-09-18 15:18:56 +00:00
}
2000-09-18 15:18:56 +00:00
sal_Bool OStatement_Base::convertFastPropertyValue(
Any & rConvertedValue,
Any & rOldValue,
sal_Int32 nHandle,
const Any& rValue )
{
bool bModified = false;
bool bValidAdoRS = m_RecordSet.IsValid();
// 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
{
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;
}
}
catch( const Exception& )
{
bModified = true; // will ensure that the property is set
OSL_FAIL( "OStatement_Base::convertFastPropertyValue: caught something strange!" );
2000-09-18 15:18:56 +00:00
}
return bModified;
2000-09-18 15:18:56 +00: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:
;
}
}
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:
rValue <<= true;
break;
2000-09-18 15:18:56 +00:00
case PROPERTY_ID_USEBOOKMARKS:
default:
;
}
}
2000-09-18 15:18:56 +00:00
OStatement::~OStatement()
{
}
IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
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();
}
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( )
2001-04-30 09:16:19 +00:00
{
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */