LCOV - code coverage report
Current view: top level - connectivity/source/drivers/file - FPreparedStatement.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 276 0.0 %
Date: 2014-04-14 Functions: 0 51 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10