1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <stdio.h> 28cdf0e10cSrcweir #include "connectivity/sdbcx/VColumn.hxx" 29cdf0e10cSrcweir #include <osl/diagnose.h> 30cdf0e10cSrcweir #include "file/FPreparedStatement.hxx" 31cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 32cdf0e10cSrcweir #include "file/FResultSetMetaData.hxx" 33cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 34cdf0e10cSrcweir #include <comphelper/sequence.hxx> 35cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 36cdf0e10cSrcweir #include "connectivity/dbconversion.hxx" 37cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 38cdf0e10cSrcweir #include "connectivity/dbtools.hxx" 39cdf0e10cSrcweir #include "connectivity/PColumn.hxx" 40cdf0e10cSrcweir #include "diagnose_ex.h" 41cdf0e10cSrcweir #include <comphelper/types.hxx> 42cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 43cdf0e10cSrcweir #include <tools/debug.hxx> 44cdf0e10cSrcweir #include "resource/file_res.hrc" 45cdf0e10cSrcweir #include <rtl/logfile.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace connectivity; 48cdf0e10cSrcweir using namespace comphelper; 49cdf0e10cSrcweir using namespace ::dbtools; 50cdf0e10cSrcweir using namespace connectivity::file; 51cdf0e10cSrcweir using namespace com::sun::star::uno; 52cdf0e10cSrcweir using namespace com::sun::star::lang; 53cdf0e10cSrcweir using namespace com::sun::star::beans; 54cdf0e10cSrcweir using namespace com::sun::star::sdbc; 55cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 56cdf0e10cSrcweir using namespace com::sun::star::container; 57cdf0e10cSrcweir using namespace com::sun::star::util; 58cdf0e10cSrcweir 59cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.PreparedStatement","com.sun.star.sdbc.PreparedStatement"); 60cdf0e10cSrcweir 61cdf0e10cSrcweir DBG_NAME( file_OPreparedStatement ) 62cdf0e10cSrcweir // ------------------------------------------------------------------------- 63cdf0e10cSrcweir OPreparedStatement::OPreparedStatement( OConnection* _pConnection) 64cdf0e10cSrcweir : OStatement_BASE2( _pConnection ) 65cdf0e10cSrcweir ,m_pResultSet(NULL) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::OPreparedStatement" ); 68cdf0e10cSrcweir DBG_CTOR( file_OPreparedStatement, NULL ); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir // ------------------------------------------------------------------------- 72cdf0e10cSrcweir OPreparedStatement::~OPreparedStatement() 73cdf0e10cSrcweir { 74cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::~OPreparedStatement" ); 75cdf0e10cSrcweir DBG_DTOR( file_OPreparedStatement, NULL ); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir // ------------------------------------------------------------------------- 79cdf0e10cSrcweir void OPreparedStatement::disposing() 80cdf0e10cSrcweir { 81cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::disposing" ); 82cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 83cdf0e10cSrcweir 84cdf0e10cSrcweir clearMyResultSet(); 85cdf0e10cSrcweir OStatement_BASE2::disposing(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir if(m_pResultSet) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir m_pResultSet->release(); 90cdf0e10cSrcweir m_pResultSet = NULL; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir m_xParamColumns = NULL; 94cdf0e10cSrcweir m_xMetaData.clear(); 95cdf0e10cSrcweir if(m_aParameterRow.isValid()) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir m_aParameterRow->get().clear(); 98cdf0e10cSrcweir m_aParameterRow = NULL; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir 102cdf0e10cSrcweir } 103cdf0e10cSrcweir // ------------------------------------------------------------------------- 104cdf0e10cSrcweir void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::construct" ); 107cdf0e10cSrcweir OStatement_Base::construct(sql); 108cdf0e10cSrcweir 109cdf0e10cSrcweir m_aParameterRow = new OValueRefVector(); 110cdf0e10cSrcweir m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); 113cdf0e10cSrcweir 114cdf0e10cSrcweir if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT ) 115cdf0e10cSrcweir m_xParamColumns = m_aSQLIterator.getParameters(); 116cdf0e10cSrcweir else 117cdf0e10cSrcweir { 118cdf0e10cSrcweir m_xParamColumns = new OSQLColumns(); 119cdf0e10cSrcweir // describe all parameters need for the resultset 120cdf0e10cSrcweir describeParameter(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir OValueRefRow aTemp; 124cdf0e10cSrcweir OResultSet::setBoundedColumns(m_aEvaluateRow,aTemp,m_xParamColumns,xNames,sal_False,m_xDBMetaData,m_aColMapping); 125cdf0e10cSrcweir 126cdf0e10cSrcweir m_pResultSet = createResultSet(); 127cdf0e10cSrcweir m_pResultSet->acquire(); 128cdf0e10cSrcweir m_xResultSet = Reference<XResultSet>(m_pResultSet); 129cdf0e10cSrcweir initializeResultSet(m_pResultSet); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir // ------------------------------------------------------------------------- 132cdf0e10cSrcweir 133cdf0e10cSrcweir Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::queryInterface" ); 136cdf0e10cSrcweir Any aRet = OStatement_BASE2::queryInterface(rType); 137cdf0e10cSrcweir return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, 138cdf0e10cSrcweir static_cast< XPreparedStatement*>(this), 139cdf0e10cSrcweir static_cast< XParameters*>(this), 140cdf0e10cSrcweir static_cast< XResultSetMetaDataSupplier*>(this)); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir // ------------------------------------------------------------------------- 143cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getTypes" ); 146cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), 147cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), 148cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 )); 149cdf0e10cSrcweir 150cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir // ------------------------------------------------------------------------- 153cdf0e10cSrcweir 154cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getMetaData" ); 157cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 158cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir if(!m_xMetaData.is()) 162cdf0e10cSrcweir m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable); 163cdf0e10cSrcweir return m_xMetaData; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir // ------------------------------------------------------------------------- 166cdf0e10cSrcweir 167cdf0e10cSrcweir void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::close" ); 170cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 171cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 172cdf0e10cSrcweir 173cdf0e10cSrcweir 174cdf0e10cSrcweir clearMyResultSet(); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir // ------------------------------------------------------------------------- 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::execute" ); 181cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 182cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 183cdf0e10cSrcweir 184cdf0e10cSrcweir initResultSet(); 185cdf0e10cSrcweir 186cdf0e10cSrcweir return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir // ------------------------------------------------------------------------- 189cdf0e10cSrcweir 190cdf0e10cSrcweir sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeUpdate" ); 193cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 194cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 195cdf0e10cSrcweir 196cdf0e10cSrcweir initResultSet(); 197cdf0e10cSrcweir 198cdf0e10cSrcweir return m_pResultSet ? m_pResultSet->getRowCountResult() : sal_Int32(0); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir // ------------------------------------------------------------------------- 201cdf0e10cSrcweir 202cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setString" ); 205cdf0e10cSrcweir setParameter(parameterIndex,x); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir // ------------------------------------------------------------------------- 208cdf0e10cSrcweir 209cdf0e10cSrcweir Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getConnection" ); 212cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 213cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 214cdf0e10cSrcweir 215cdf0e10cSrcweir return (Reference< XConnection >)m_pConnection; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir // ------------------------------------------------------------------------- 218cdf0e10cSrcweir 219cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeQuery" ); 222cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 223cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 224cdf0e10cSrcweir 225cdf0e10cSrcweir return initResultSet(); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir // ------------------------------------------------------------------------- 228cdf0e10cSrcweir 229cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBoolean" ); 232cdf0e10cSrcweir setParameter(parameterIndex,x); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir // ------------------------------------------------------------------------- 235cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setByte" ); 238cdf0e10cSrcweir setParameter(parameterIndex,x); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir // ------------------------------------------------------------------------- 241cdf0e10cSrcweir 242cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDate" ); 245cdf0e10cSrcweir setParameter(parameterIndex,DBTypeConversion::toDouble(aData)); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir // ------------------------------------------------------------------------- 248cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTime" ); 251cdf0e10cSrcweir setParameter(parameterIndex,DBTypeConversion::toDouble(aVal)); 252cdf0e10cSrcweir } 253cdf0e10cSrcweir // ------------------------------------------------------------------------- 254cdf0e10cSrcweir 255cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTimestamp" ); 258cdf0e10cSrcweir setParameter(parameterIndex,DBTypeConversion::toDouble(aVal)); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir // ------------------------------------------------------------------------- 261cdf0e10cSrcweir 262cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDouble" ); 265cdf0e10cSrcweir setParameter(parameterIndex,x); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir // ------------------------------------------------------------------------- 269cdf0e10cSrcweir 270cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setFloat" ); 273cdf0e10cSrcweir setParameter(parameterIndex,x); 274cdf0e10cSrcweir } 275cdf0e10cSrcweir // ------------------------------------------------------------------------- 276cdf0e10cSrcweir 277cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setInt" ); 280cdf0e10cSrcweir setParameter(parameterIndex,x); 281cdf0e10cSrcweir } 282cdf0e10cSrcweir // ------------------------------------------------------------------------- 283cdf0e10cSrcweir 284cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setLong" ); 287cdf0e10cSrcweir throwFeatureNotImplementedException( "XParameters::setLong", *this ); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir // ------------------------------------------------------------------------- 290cdf0e10cSrcweir 291cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setNull" ); 294cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 295cdf0e10cSrcweir checkAndResizeParameters(parameterIndex); 296cdf0e10cSrcweir 297cdf0e10cSrcweir if ( m_aAssignValues.isValid() ) 298cdf0e10cSrcweir (m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]]->setNull(); 299cdf0e10cSrcweir else 300cdf0e10cSrcweir (m_aParameterRow->get())[parameterIndex]->setNull(); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir // ------------------------------------------------------------------------- 303cdf0e10cSrcweir 304cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setClob" ); 307cdf0e10cSrcweir throwFeatureNotImplementedException( "XParameters::setClob", *this ); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir // ------------------------------------------------------------------------- 310cdf0e10cSrcweir 311cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBlob" ); 314cdf0e10cSrcweir throwFeatureNotImplementedException( "XParameters::setBlob", *this ); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir // ------------------------------------------------------------------------- 317cdf0e10cSrcweir 318cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setArray" ); 321cdf0e10cSrcweir throwFeatureNotImplementedException( "XParameters::setArray", *this ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir // ------------------------------------------------------------------------- 324cdf0e10cSrcweir 325cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setRef" ); 328cdf0e10cSrcweir throwFeatureNotImplementedException( "XParameters::setRef", *this ); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir // ------------------------------------------------------------------------- 331cdf0e10cSrcweir 332cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectWithInfo" ); 335cdf0e10cSrcweir switch(sqlType) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir case DataType::DECIMAL: 338cdf0e10cSrcweir case DataType::NUMERIC: 339cdf0e10cSrcweir setString(parameterIndex,::comphelper::getString(x)); 340cdf0e10cSrcweir break; 341cdf0e10cSrcweir default: 342cdf0e10cSrcweir ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale); 343cdf0e10cSrcweir break; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir } 346cdf0e10cSrcweir // ------------------------------------------------------------------------- 347cdf0e10cSrcweir 348cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectNull" ); 351cdf0e10cSrcweir setNull(parameterIndex,sqlType); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir // ------------------------------------------------------------------------- 354cdf0e10cSrcweir 355cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObject" ); 358cdf0e10cSrcweir if(!::dbtools::implSetObject(this,parameterIndex,x)) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( 361cdf0e10cSrcweir STR_UNKNOWN_PARA_TYPE, 362cdf0e10cSrcweir "$position$", ::rtl::OUString::valueOf(parameterIndex) 363cdf0e10cSrcweir ) ); 364cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir // setObject (parameterIndex, x, sqlType, 0); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir // ------------------------------------------------------------------------- 369cdf0e10cSrcweir 370cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setShort" ); 373cdf0e10cSrcweir setParameter(parameterIndex,x); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir // ------------------------------------------------------------------------- 376cdf0e10cSrcweir 377cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBytes" ); 380cdf0e10cSrcweir setParameter(parameterIndex,x); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir // ------------------------------------------------------------------------- 383cdf0e10cSrcweir 384cdf0e10cSrcweir 385cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setCharacterStream" ); 388cdf0e10cSrcweir setBinaryStream(parameterIndex,x,length ); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir // ------------------------------------------------------------------------- 391cdf0e10cSrcweir 392cdf0e10cSrcweir void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBinaryStream" ); 395cdf0e10cSrcweir if(!x.is()) 396cdf0e10cSrcweir ::dbtools::throwFunctionSequenceException(*this); 397cdf0e10cSrcweir 398cdf0e10cSrcweir Sequence<sal_Int8> aSeq; 399cdf0e10cSrcweir x->readBytes(aSeq,length); 400cdf0e10cSrcweir setParameter(parameterIndex,aSeq); 401cdf0e10cSrcweir } 402cdf0e10cSrcweir // ------------------------------------------------------------------------- 403cdf0e10cSrcweir 404cdf0e10cSrcweir void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::clearParameters" ); 407cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 408cdf0e10cSrcweir checkDisposed(OStatement_BASE::rBHelper.bDisposed); 409cdf0e10cSrcweir 410cdf0e10cSrcweir m_aParameterRow->get().clear(); 411cdf0e10cSrcweir m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) ); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir // ------------------------------------------------------------------------- 414cdf0e10cSrcweir OResultSet* OPreparedStatement::createResultSet() 415cdf0e10cSrcweir { 416cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::createResultSet" ); 417cdf0e10cSrcweir return new OResultSet(this,m_aSQLIterator); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir // ----------------------------------------------------------------------------- 420cdf0e10cSrcweir Reference<XResultSet> OPreparedStatement::initResultSet() 421cdf0e10cSrcweir { 422cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initResultSet" ); 423cdf0e10cSrcweir m_pResultSet->clear(); 424cdf0e10cSrcweir Reference<XResultSet> xRs(m_pResultSet); 425cdf0e10cSrcweir 426cdf0e10cSrcweir // check if we got enough paramters 427cdf0e10cSrcweir if ( (m_aParameterRow.isValid() && ( m_aParameterRow->get().size() -1 ) < m_xParamColumns->get().size()) || 428cdf0e10cSrcweir (m_xParamColumns.isValid() && !m_aParameterRow.isValid() && !m_aParameterRow->get().empty()) ) 429cdf0e10cSrcweir m_pConnection->throwGenericSQLException(STR_INVALID_PARA_COUNT,*this); 430cdf0e10cSrcweir 431cdf0e10cSrcweir m_pResultSet->OpenImpl(); 432cdf0e10cSrcweir m_pResultSet->setMetaData(getMetaData()); 433cdf0e10cSrcweir 434cdf0e10cSrcweir return xRs; 435cdf0e10cSrcweir } 436cdf0e10cSrcweir // ----------------------------------------------------------------------------- 437cdf0e10cSrcweir void SAL_CALL OPreparedStatement::acquire() throw() 438cdf0e10cSrcweir { 439cdf0e10cSrcweir OStatement_BASE2::acquire(); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir // ----------------------------------------------------------------------------- 442cdf0e10cSrcweir void SAL_CALL OPreparedStatement::release() throw() 443cdf0e10cSrcweir { 444cdf0e10cSrcweir OStatement_BASE2::release(); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir // ----------------------------------------------------------------------------- 447cdf0e10cSrcweir void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::checkAndResizeParameters" ); 450cdf0e10cSrcweir ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed); 451cdf0e10cSrcweir if ( m_aAssignValues.isValid() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) ) 452cdf0e10cSrcweir throwInvalidIndexException(*this); 453cdf0e10cSrcweir else if ( static_cast<sal_Int32>((m_aParameterRow->get()).size()) <= parameterIndex ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir sal_Int32 i = m_aParameterRow->get().size(); 456cdf0e10cSrcweir (m_aParameterRow->get()).resize(parameterIndex+1); 457cdf0e10cSrcweir for ( ;i <= parameterIndex+1; ++i ) 458cdf0e10cSrcweir { 459cdf0e10cSrcweir if ( !(m_aParameterRow->get())[i].isValid() ) 460cdf0e10cSrcweir (m_aParameterRow->get())[i] = new ORowSetValueDecorator; 461cdf0e10cSrcweir } 462cdf0e10cSrcweir } 463cdf0e10cSrcweir } 464cdf0e10cSrcweir // ----------------------------------------------------------------------------- 465cdf0e10cSrcweir void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setParameter" ); 468cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 469cdf0e10cSrcweir checkAndResizeParameters(parameterIndex); 470cdf0e10cSrcweir 471cdf0e10cSrcweir if(m_aAssignValues.isValid()) 472cdf0e10cSrcweir *(m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]] = x; 473cdf0e10cSrcweir else 474cdf0e10cSrcweir *((m_aParameterRow->get())[parameterIndex]) = x; 475cdf0e10cSrcweir } 476cdf0e10cSrcweir // ----------------------------------------------------------------------------- 477cdf0e10cSrcweir sal_uInt32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::AddParameter" ); 480cdf0e10cSrcweir OSL_UNUSED( pParameter ); 481cdf0e10cSrcweir OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter"); 482cdf0e10cSrcweir OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree"); 483cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 484cdf0e10cSrcweir OSQLParseNode * pMark = pParameter->getChild(0); 485cdf0e10cSrcweir OSL_UNUSED( pMark ); 486cdf0e10cSrcweir #endif 487cdf0e10cSrcweir 488cdf0e10cSrcweir ::rtl::OUString sParameterName; 489cdf0e10cSrcweir // Parameter-Column aufsetzen: 490cdf0e10cSrcweir sal_Int32 eType = DataType::VARCHAR; 491cdf0e10cSrcweir sal_uInt32 nPrecision = 255; 492cdf0e10cSrcweir sal_Int32 nScale = 0; 493cdf0e10cSrcweir sal_Int32 nNullable = ColumnValue::NULLABLE; 494cdf0e10cSrcweir 495cdf0e10cSrcweir if (_xCol.is()) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir // Typ, Precision, Scale ... der angegebenen Column verwenden, 498cdf0e10cSrcweir // denn dieser Column wird der Wert zugewiesen bzw. mit dieser 499cdf0e10cSrcweir // Column wird der Wert verglichen. 500cdf0e10cSrcweir _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= eType; 501cdf0e10cSrcweir _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nPrecision; 502cdf0e10cSrcweir _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale; 503cdf0e10cSrcweir _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNullable; 504cdf0e10cSrcweir _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName; 505cdf0e10cSrcweir } 506cdf0e10cSrcweir 507cdf0e10cSrcweir Reference<XPropertySet> xParaColumn = new connectivity::parse::OParseColumn(sParameterName 508cdf0e10cSrcweir ,::rtl::OUString() 509cdf0e10cSrcweir ,::rtl::OUString() 510cdf0e10cSrcweir ,::rtl::OUString() 511cdf0e10cSrcweir ,nNullable 512cdf0e10cSrcweir ,nPrecision 513cdf0e10cSrcweir ,nScale 514cdf0e10cSrcweir ,eType 515cdf0e10cSrcweir ,sal_False 516cdf0e10cSrcweir ,sal_False 517cdf0e10cSrcweir ,m_aSQLIterator.isCaseSensitive()); 518cdf0e10cSrcweir m_xParamColumns->get().push_back(xParaColumn); 519cdf0e10cSrcweir return m_xParamColumns->get().size(); 520cdf0e10cSrcweir } 521cdf0e10cSrcweir // ----------------------------------------------------------------------------- 522cdf0e10cSrcweir void OPreparedStatement::describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeColumn" ); 525cdf0e10cSrcweir Reference<XPropertySet> xProp; 526cdf0e10cSrcweir if(SQL_ISRULE(_pNode,column_ref)) 527cdf0e10cSrcweir { 528cdf0e10cSrcweir ::rtl::OUString sColumnName,sTableRange; 529cdf0e10cSrcweir m_aSQLIterator.getColumnRange(_pNode,sColumnName,sTableRange); 530cdf0e10cSrcweir if ( sColumnName.getLength() ) 531cdf0e10cSrcweir { 532cdf0e10cSrcweir Reference<XNameAccess> xNameAccess = _xTable->getColumns(); 533cdf0e10cSrcweir if(xNameAccess->hasByName(sColumnName)) 534cdf0e10cSrcweir xNameAccess->getByName(sColumnName) >>= xProp; 535cdf0e10cSrcweir AddParameter(_pParameter,xProp); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir } 538cdf0e10cSrcweir // else 539cdf0e10cSrcweir // AddParameter(_pParameter,xProp); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir // ------------------------------------------------------------------------- 542cdf0e10cSrcweir void OPreparedStatement::describeParameter() 543cdf0e10cSrcweir { 544cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeParameter" ); 545cdf0e10cSrcweir ::std::vector< OSQLParseNode*> aParseNodes; 546cdf0e10cSrcweir scanParameter(m_pParseTree,aParseNodes); 547cdf0e10cSrcweir if ( !aParseNodes.empty() ) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir // m_xParamColumns = new OSQLColumns(); 550cdf0e10cSrcweir const OSQLTables& xTabs = m_aSQLIterator.getTables(); 551cdf0e10cSrcweir if( !xTabs.empty() ) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir OSQLTable xTable = xTabs.begin()->second; 554cdf0e10cSrcweir ::std::vector< OSQLParseNode*>::const_iterator aIter = aParseNodes.begin(); 555cdf0e10cSrcweir for (;aIter != aParseNodes.end();++aIter ) 556cdf0e10cSrcweir { 557cdf0e10cSrcweir describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir } 560cdf0e10cSrcweir } 561cdf0e10cSrcweir } 562cdf0e10cSrcweir // ----------------------------------------------------------------------------- 563cdf0e10cSrcweir void OPreparedStatement::initializeResultSet(OResultSet* _pResult) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initializeResultSet" ); 566cdf0e10cSrcweir OStatement_Base::initializeResultSet(_pResult); 567cdf0e10cSrcweir 568cdf0e10cSrcweir m_pResultSet->setParameterColumns(m_xParamColumns); 569cdf0e10cSrcweir m_pResultSet->setParameterRow(m_aParameterRow); 570cdf0e10cSrcweir 571cdf0e10cSrcweir // Parameter substituieren (AssignValues und Kriterien): 572cdf0e10cSrcweir if (!m_xParamColumns->get().empty()) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir // Zunaechst AssignValues 575cdf0e10cSrcweir sal_uInt16 nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an 576cdf0e10cSrcweir 577cdf0e10cSrcweir // Nach zu substituierenden Parametern suchen: 578cdf0e10cSrcweir size_t nCount = m_aAssignValues.isValid() ? m_aAssignValues->get().size() : 1; // 1 ist wichtig fuer die Kriterien 579cdf0e10cSrcweir for (size_t j = 1; j < nCount; j++) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir sal_uInt32 nParameter = (*m_aAssignValues).getParameterIndex(j); 582cdf0e10cSrcweir if (nParameter == SQL_NO_PARAMETER) 583cdf0e10cSrcweir continue; // dieser AssignValue ist kein Parameter 584cdf0e10cSrcweir 585cdf0e10cSrcweir ++nParaCount; // ab hier ist der Parameter gueltig 586cdf0e10cSrcweir // Parameter ersetzen. Wenn Parameter nicht verfuegbar, 587cdf0e10cSrcweir // Value auf NULL setzen. 588cdf0e10cSrcweir // (*m_aAssignValues)[j] = (*m_aParameterRow)[(sal_uInt16)nParameter]; 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir if (m_aParameterRow.isValid() && (m_xParamColumns->get().size()+1) != m_aParameterRow->get().size() ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir sal_Int32 i = m_aParameterRow->get().size(); 594cdf0e10cSrcweir sal_Int32 nParamColumns = m_xParamColumns->get().size()+1; 595cdf0e10cSrcweir m_aParameterRow->get().resize(nParamColumns); 596cdf0e10cSrcweir for ( ;i < nParamColumns; ++i ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir if ( !(m_aParameterRow->get())[i].isValid() ) 599cdf0e10cSrcweir (m_aParameterRow->get())[i] = new ORowSetValueDecorator; 600cdf0e10cSrcweir } 601cdf0e10cSrcweir //m_aParameterRow->resize(m_xParamColumns->size()+1); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->get().size() ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir 606cdf0e10cSrcweir m_pSQLAnalyzer->bindParameterRow(m_aParameterRow); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir } 609cdf0e10cSrcweir } 610cdf0e10cSrcweir // ----------------------------------------------------------------------------- 611cdf0e10cSrcweir void OPreparedStatement::parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::parseParamterElem" ); 614cdf0e10cSrcweir Reference<XPropertySet> xCol; 615cdf0e10cSrcweir m_xColNames->getByName(_sColumnName) >>= xCol; 616cdf0e10cSrcweir sal_Int32 nParameter = -1; 617cdf0e10cSrcweir if(m_xParamColumns.isValid()) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir OSQLColumns::Vector::const_iterator aIter = find(m_xParamColumns->get().begin(),m_xParamColumns->get().end(),_sColumnName,::comphelper::UStringMixEqual(m_pTable->isCaseSensitive())); 620cdf0e10cSrcweir if(aIter != m_xParamColumns->get().end()) 621cdf0e10cSrcweir nParameter = m_xParamColumns->get().size() - (m_xParamColumns->get().end() - aIter) + 1;// +1 because the rows start at 1 622cdf0e10cSrcweir } 623cdf0e10cSrcweir if(nParameter == -1) 624cdf0e10cSrcweir nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol); 625cdf0e10cSrcweir // Nr. des Parameters in der Variablen merken: 626cdf0e10cSrcweir SetAssignValue(_sColumnName, String(), sal_True, nParameter); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir // ----------------------------------------------------------------------------- 629cdf0e10cSrcweir 630cdf0e10cSrcweir 631