LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/odbcbase - OStatement.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 471 0.0 %
Date: 2012-12-27 Functions: 0 70 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 <osl/diagnose.h>
      23             : #include "odbc/OStatement.hxx"
      24             : #include "odbc/OConnection.hxx"
      25             : #include "odbc/OResultSet.hxx"
      26             : #include <comphelper/property.hxx>
      27             : #include "odbc/OTools.hxx"
      28             : #include <comphelper/uno3.hxx>
      29             : #include <osl/thread.h>
      30             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      31             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      32             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      33             : #include <com/sun/star/lang/DisposedException.hpp>
      34             : #include <comphelper/sequence.hxx>
      35             : #include <cppuhelper/typeprovider.hxx>
      36             : #include <comphelper/extract.hxx>
      37             : #include <comphelper/types.hxx>
      38             : #include "diagnose_ex.h"
      39             : #include <algorithm>
      40             : #include "resource/common_res.hrc"
      41             : #include "connectivity/dbexception.hxx"
      42             : 
      43             : using namespace ::comphelper;
      44             : 
      45             : #define THROW_SQL(x) \
      46             :     OTools::ThrowException(m_pConnection,x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
      47             : 
      48             : 
      49             : 
      50             : using namespace connectivity::odbc;
      51             : //------------------------------------------------------------------------------
      52             : using namespace com::sun::star::uno;
      53             : using namespace com::sun::star::lang;
      54             : using namespace com::sun::star::beans;
      55             : using namespace com::sun::star::sdbc;
      56             : using namespace com::sun::star::sdbcx;
      57             : using namespace com::sun::star::container;
      58             : using namespace com::sun::star::io;
      59             : using namespace com::sun::star::util;
      60             : //------------------------------------------------------------------------------
      61           0 : OStatement_Base::OStatement_Base(OConnection* _pConnection )
      62             :     :OStatement_BASE(m_aMutex)
      63             :     ,OPropertySetHelper(OStatement_BASE::rBHelper)
      64             :     ,m_pConnection(_pConnection)
      65             :     ,m_aStatementHandle(SQL_NULL_HANDLE)
      66             :     ,m_pRowStatusArray(0)
      67           0 :     ,rBHelper(OStatement_BASE::rBHelper)
      68             : {
      69           0 :     osl_atomic_increment( &m_refCount );
      70           0 :     m_pConnection->acquire();
      71           0 :     m_aStatementHandle = m_pConnection->createStatementHandle();
      72             : 
      73             :     //setMaxFieldSize(0);
      74             :     // Don't do this. By ODBC spec, "0" is the default for the SQL_ATTR_MAX_LENGTH attribute. We once introduced
      75             :     // this line since an PostgreSQL ODBC driver had a default other than 0. However, current drivers (at least 8.3
      76             :     // and later) have a proper default of 0, so there should be no need anymore.
      77             :     // On the other hand, the NotesSQL driver (IBM's ODBC driver for the Lotus Notes series) wrongly interprets
      78             :     // "0" as "0", whereas the ODBC spec says it should in fact mean "unlimited".
      79             :     // So, removing this line seems to be the best option for now.
      80             :     // If we ever again encounter a ODBC driver which needs this option, then we should introduce a data source
      81             :     // setting for it, instead of unconditionally doing it.
      82             : 
      83           0 :     osl_atomic_decrement( &m_refCount );
      84           0 : }
      85             : // -----------------------------------------------------------------------------
      86           0 : OStatement_Base::~OStatement_Base()
      87             : {
      88             :     OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
      89           0 : }
      90             : //------------------------------------------------------------------------------
      91           0 : void OStatement_Base::disposeResultSet()
      92             : {
      93             :     // free the cursor if alive
      94           0 :     Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
      95           0 :     if (xComp.is())
      96           0 :         xComp->dispose();
      97           0 :     m_xResultSet = Reference< XResultSet>();
      98           0 : }
      99             : // -----------------------------------------------------------------------------
     100           0 : void SAL_CALL OStatement_Base::disposing(void)
     101             : {
     102           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     103             : 
     104           0 :     disposeResultSet();
     105           0 :     ::comphelper::disposeComponent(m_xGeneratedStatement);
     106             : 
     107             :     OSL_ENSURE(m_aStatementHandle,"OStatement_BASE2::disposing: StatementHandle is null!");
     108           0 :     if (m_pConnection)
     109             :     {
     110           0 :         m_pConnection->freeStatementHandle(m_aStatementHandle);
     111           0 :         m_pConnection->release();
     112           0 :         m_pConnection = NULL;
     113             :     }
     114             :     OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
     115             : 
     116           0 :     OStatement_BASE::disposing();
     117           0 : }
     118             : //------------------------------------------------------------------------------
     119           0 : void OStatement_BASE2::disposing()
     120             : {
     121           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     122             : 
     123           0 :     dispose_ChildImpl();
     124           0 :     OStatement_Base::disposing();
     125           0 : }
     126             : //-----------------------------------------------------------------------------
     127           0 : void SAL_CALL OStatement_BASE2::release() throw()
     128             : {
     129           0 :     relase_ChildImpl();
     130           0 : }
     131             : //-----------------------------------------------------------------------------
     132           0 : Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
     133             : {
     134           0 :     if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) )
     135           0 :         return Any();
     136           0 :     Any aRet = OStatement_BASE::queryInterface(rType);
     137           0 :     return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
     138             : }
     139             : // -------------------------------------------------------------------------
     140           0 : Sequence< Type > SAL_CALL OStatement_Base::getTypes(  ) throw(RuntimeException)
     141             : {
     142           0 :     ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
     143           0 :                                     ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
     144           0 :                                     ::getCppuType( (const Reference< XPropertySet > *)0 ));
     145           0 :     Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
     146           0 :     if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
     147             :     {
     148           0 :         ::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
     149           0 :                         ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ));
     150           0 :         aOldTypes.realloc(aOldTypes.getLength() - 1);
     151             :     }
     152             : 
     153           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
     154             : }
     155             : // -------------------------------------------------------------------------
     156           0 : Reference< XResultSet > SAL_CALL OStatement_Base::getGeneratedValues(  ) throw (SQLException, RuntimeException)
     157             : {
     158             :     OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
     159           0 :     Reference< XResultSet > xRes;
     160           0 :     if ( m_pConnection )
     161             :     {
     162           0 :         ::rtl::OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
     163           0 :         if ( !sStmt.isEmpty() )
     164             :         {
     165           0 :             ::comphelper::disposeComponent(m_xGeneratedStatement);
     166           0 :             m_xGeneratedStatement = m_pConnection->createStatement();
     167           0 :             xRes = m_xGeneratedStatement->executeQuery(sStmt);
     168           0 :         }
     169             :     }
     170           0 :     return xRes;
     171             : }
     172             : // -----------------------------------------------------------------------------
     173           0 : void SAL_CALL OStatement_Base::cancel(  ) throw(RuntimeException)
     174             : {
     175           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     176           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     177             : 
     178             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     179           0 :     OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     180           0 : }
     181             : // -------------------------------------------------------------------------
     182             : 
     183           0 : void SAL_CALL OStatement_Base::close(  ) throw(SQLException, RuntimeException)
     184             : {
     185             :     {
     186           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     187           0 :         checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     188             : 
     189             :     }
     190           0 :     dispose();
     191           0 : }
     192             : // -------------------------------------------------------------------------
     193             : 
     194           0 : void SAL_CALL OStatement::clearBatch(  ) throw(SQLException, RuntimeException)
     195             : {
     196             : 
     197           0 : }
     198             : // -------------------------------------------------------------------------
     199             : 
     200           0 : void OStatement_Base::reset() throw (SQLException)
     201             : {
     202           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     203           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     204             : 
     205             : 
     206           0 :     clearWarnings ();
     207             : 
     208           0 :     if (m_xResultSet.get().is())
     209             :     {
     210           0 :         clearMyResultSet();
     211             :     }
     212           0 :     if(m_aStatementHandle)
     213             :     {
     214           0 :         THROW_SQL(N3SQLFreeStmt(m_aStatementHandle, SQL_CLOSE));
     215           0 :     }
     216           0 : }
     217             : //--------------------------------------------------------------------
     218             : // clearMyResultSet
     219             : // If a ResultSet was created for this Statement, close it
     220             : //--------------------------------------------------------------------
     221             : 
     222           0 : void OStatement_Base::clearMyResultSet () throw (SQLException)
     223             : {
     224           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     225           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     226             : 
     227             :     try
     228             :     {
     229           0 :         Reference<XCloseable> xCloseable;
     230           0 :         if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
     231           0 :             xCloseable->close();
     232             :     }
     233           0 :     catch( const DisposedException& ) { }
     234             : 
     235           0 :     m_xResultSet = Reference< XResultSet >();
     236           0 : }
     237             : //--------------------------------------------------------------------
     238           0 : SQLLEN OStatement_Base::getRowCount () throw( SQLException)
     239             : {
     240           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     241           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     242             : 
     243             : 
     244           0 :     SQLLEN numRows = 0;
     245             : 
     246             :     try {
     247           0 :         THROW_SQL(N3SQLRowCount(m_aStatementHandle,&numRows));
     248             :     }
     249           0 :     catch (const SQLException&)
     250             :     {
     251             :     }
     252           0 :     return numRows;
     253             : }
     254             : //--------------------------------------------------------------------
     255             : // lockIfNecessary
     256             : // If the given SQL statement contains a 'FOR UPDATE' clause, change
     257             : // the concurrency to lock so that the row can then be updated.  Returns
     258             : // true if the concurrency has been changed
     259             : //--------------------------------------------------------------------
     260             : 
     261           0 : sal_Bool OStatement_Base::lockIfNecessary (const ::rtl::OUString& sql) throw( SQLException)
     262             : {
     263           0 :     sal_Bool rc = sal_False;
     264             : 
     265             :     // First, convert the statement to upper case
     266             : 
     267           0 :     ::rtl::OUString sqlStatement = sql.toAsciiUpperCase ();
     268             : 
     269             :     // Now, look for the FOR UPDATE keywords.  If there is any extra white
     270             :     // space between the FOR and UPDATE, this will fail.
     271             : 
     272           0 :     sal_Int32 index = sqlStatement.indexOf(" FOR UPDATE");
     273             : 
     274             :     // We found it.  Change our concurrency level to ensure that the
     275             :     // row can be updated.
     276             : 
     277           0 :     if (index > 0)
     278             :     {
     279             :         OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     280             :         try
     281             :         {
     282           0 :             THROW_SQL((setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CONCURRENCY, SQL_CONCUR_LOCK)));
     283             :         }
     284           0 :         catch (const SQLWarning& warn)
     285             :         {
     286             :             // Catch any warnings and place on the warning stack
     287           0 :             setWarning (warn);
     288             :         }
     289           0 :         rc = sal_True;
     290             :     }
     291             : 
     292           0 :     return rc;
     293             : }
     294             : //--------------------------------------------------------------------
     295             : // setWarning
     296             : // Sets the warning
     297             : //--------------------------------------------------------------------
     298             : 
     299           0 : void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
     300             : {
     301           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     302           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     303             : 
     304             : 
     305           0 :     m_aLastWarning = ex;
     306           0 : }
     307             : 
     308             : //--------------------------------------------------------------------
     309             : // getColumnCount
     310             : // Return the number of columns in the ResultSet
     311             : //--------------------------------------------------------------------
     312             : 
     313           0 : sal_Int32 OStatement_Base::getColumnCount () throw( SQLException)
     314             : {
     315           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     316           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     317             : 
     318             : 
     319           0 :     sal_Int16   numCols = 0;
     320             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     321             : 
     322             :     try {
     323           0 :         THROW_SQL(N3SQLNumResultCols(m_aStatementHandle,&numCols));
     324             :     }
     325           0 :     catch (const SQLException&)
     326             :     {
     327             :     }
     328           0 :     return numCols;
     329             : }
     330             : // -------------------------------------------------------------------------
     331             : 
     332           0 : sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
     333             : {
     334           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     335           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     336           0 :     m_sSqlStatement = sql;
     337             : 
     338             : 
     339           0 :     ::rtl::OString aSql(::rtl::OUStringToOString(sql,getOwnConnection()->getTextEncoding()));
     340             : 
     341           0 :     sal_Bool hasResultSet = sal_False;
     342           0 :     SQLWarning aWarning;
     343             : 
     344             :     // Reset the statement handle and warning
     345             : 
     346           0 :     reset();
     347             : 
     348             :     // Check for a 'FOR UPDATE' statement.  If present, change
     349             :     // the concurrency to lock
     350             : 
     351           0 :     lockIfNecessary (sql);
     352             : 
     353             :     // Call SQLExecDirect
     354             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     355             : 
     356             :     try {
     357           0 :         THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aSql.getStr(),aSql.getLength()));
     358             :     }
     359           0 :     catch (const SQLWarning& ex) {
     360             : 
     361             :         // Save pointer to warning and save with ResultSet
     362             :         // object once it is created.
     363             : 
     364           0 :         aWarning = ex;
     365             :     }
     366             : 
     367             :     // Now determine if there is a result set associated with
     368             :     // the SQL statement that was executed.  Get the column
     369             :     // count, and if it is not zero, there is a result set.
     370             : 
     371           0 :     if (getColumnCount () > 0)
     372             :     {
     373           0 :         hasResultSet = sal_True;
     374             :     }
     375             : 
     376           0 :     return hasResultSet;
     377             : }
     378             : //--------------------------------------------------------------------
     379             : // getResultSet
     380             : // getResultSet returns the current result as a ResultSet.  It
     381             : // returns NULL if the current result is not a ResultSet.
     382             : //--------------------------------------------------------------------
     383           0 : Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) throw( SQLException)
     384             : {
     385           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     386           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     387             : 
     388             : 
     389           0 :     if (m_xResultSet.get().is())  // if resultset already retrieved,
     390             :     {
     391             :         // throw exception to avoid sequence error
     392           0 :         ::dbtools::throwFunctionSequenceException(*this,Any());
     393             :     }
     394             : 
     395           0 :     OResultSet* pRs = NULL;
     396           0 :     sal_Int32 numCols = 1;
     397             : 
     398             :     // If we already know we have result columns, checkCount
     399             :     // is false.  This is an optimization to prevent unneeded
     400             :     // calls to getColumnCount
     401             : 
     402           0 :     if (checkCount)
     403           0 :         numCols = getColumnCount ();
     404             : 
     405             :     // Only return a result set if there are result columns
     406             : 
     407           0 :     if (numCols > 0)
     408             :     {
     409             :         OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     410           0 :         pRs = createResulSet();
     411           0 :         pRs->construct();
     412             : 
     413             :         // Save a copy of our last result set
     414             :         // Changed to save copy at getResultSet.
     415             :         //m_xResultSet = rs;
     416             :     }
     417             :     else
     418           0 :         clearMyResultSet ();
     419             : 
     420           0 :     return pRs;
     421             : }
     422             : //--------------------------------------------------------------------
     423             : // getStmtOption
     424             : // Invoke SQLGetStmtOption with the given option.
     425             : //--------------------------------------------------------------------
     426             : 
     427           0 : template < typename T, SQLINTEGER BufferLength > T OStatement_Base::getStmtOption (SQLINTEGER fOption, T dflt) const
     428             : {
     429           0 :     T result (dflt);
     430             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     431           0 :     N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, NULL);
     432           0 :     return result;
     433             : }
     434           0 : template < typename T, SQLINTEGER BufferLength > SQLRETURN OStatement_Base::setStmtOption (SQLINTEGER fOption, T value) const
     435             : {
     436             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     437           0 :     SQLPOINTER sv = reinterpret_cast<SQLPOINTER>(value);
     438           0 :     return N3SQLSetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength);
     439             : }
     440             : // -------------------------------------------------------------------------
     441             : 
     442           0 : Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
     443             : {
     444           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     445           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     446             : 
     447             : 
     448           0 :     Reference< XResultSet > xRS = NULL;
     449             : 
     450             :     // Execute the statement.  If execute returns true, a result
     451             :     // set exists.
     452             : 
     453           0 :     if (execute (sql))
     454             :     {
     455           0 :         xRS = getResultSet (sal_False);
     456           0 :         m_xResultSet = xRS;
     457             :     }
     458             :     else
     459             :     {
     460             :         // No ResultSet was produced.  Raise an exception
     461           0 :         m_pConnection->throwGenericSQLException(STR_NO_RESULTSET,*this);
     462             :     }
     463           0 :     return xRS;
     464             : }
     465             : // -------------------------------------------------------------------------
     466             : 
     467           0 : Reference< XConnection > SAL_CALL OStatement_Base::getConnection(  ) throw(SQLException, RuntimeException)
     468             : {
     469           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     470           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     471             : 
     472           0 :     return (Reference< XConnection >)m_pConnection;
     473             : }
     474             : // -------------------------------------------------------------------------
     475             : 
     476           0 : Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
     477             : {
     478           0 :     Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
     479           0 :     return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
     480             : }
     481             : // -------------------------------------------------------------------------
     482             : 
     483           0 : void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
     484             : {
     485           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     486           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     487             : 
     488             : 
     489           0 :     m_aBatchList.push_back(sql);
     490           0 : }
     491             : // -------------------------------------------------------------------------
     492           0 : Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch(  ) throw(SQLException, RuntimeException)
     493             : {
     494           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     495           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     496             : 
     497             : 
     498           0 :     ::rtl::OString aBatchSql;
     499           0 :     sal_Int32 nLen = 0;
     500           0 :     for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
     501             :     {
     502           0 :         aBatchSql += ::rtl::OUStringToOString(*i,getOwnConnection()->getTextEncoding());
     503           0 :         aBatchSql += ";";
     504             :     }
     505             : 
     506             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     507           0 :     THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aBatchSql.getStr(),aBatchSql.getLength()));
     508             : 
     509           0 :     Sequence< sal_Int32 > aRet(nLen);
     510           0 :     sal_Int32* pArray = aRet.getArray();
     511           0 :     for(sal_Int32 j=0;j<nLen;++j)
     512             :     {
     513           0 :         SQLRETURN nError = N3SQLMoreResults(m_aStatementHandle);
     514           0 :         if(nError == SQL_SUCCESS)
     515             :         {
     516           0 :             SQLLEN nRowCount=0;
     517           0 :             N3SQLRowCount(m_aStatementHandle,&nRowCount);
     518           0 :             pArray[j] = nRowCount;
     519             :         }
     520             :     }
     521           0 :     return aRet;
     522             : }
     523             : // -------------------------------------------------------------------------
     524             : 
     525             : 
     526           0 : sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
     527             : {
     528           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     529           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     530             : 
     531             : 
     532           0 :     sal_Int32 numRows = -1;
     533             : 
     534             :     // Execute the statement.  If execute returns false, a
     535             :     // row count exists.
     536             : 
     537           0 :     if (!execute (sql)) {
     538           0 :         numRows = getUpdateCount();
     539             :     }
     540             :     else {
     541             : 
     542             :         // No update count was produced (a ResultSet was).  Raise
     543             :         // an exception
     544             : 
     545           0 :         ::connectivity::SharedResources aResources;
     546           0 :         const ::rtl::OUString sError( aResources.getResourceString(STR_NO_ROWCOUNT));
     547           0 :         throw SQLException (sError, *this,::rtl::OUString(),0,Any());
     548             :     }
     549           0 :     return numRows;
     550             : 
     551             : }
     552             : // -------------------------------------------------------------------------
     553             : 
     554           0 : Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet(  ) throw(SQLException, RuntimeException)
     555             : {
     556           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     557           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     558             : 
     559             : 
     560           0 :     m_xResultSet = getResultSet(sal_True);
     561           0 :     return m_xResultSet;
     562             : }
     563             : // -------------------------------------------------------------------------
     564             : 
     565           0 : sal_Int32 SAL_CALL OStatement_Base::getUpdateCount(  ) throw(SQLException, RuntimeException)
     566             : {
     567           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     568           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     569             : 
     570             : 
     571           0 :     sal_Int32 rowCount = -1;
     572             : 
     573             :     // Only return a row count for SQL statements that did not
     574             :     // return a result set.
     575             : 
     576           0 :     if (getColumnCount () == 0)
     577           0 :         rowCount = getRowCount ();
     578             : 
     579           0 :     return rowCount;
     580             : }
     581             : // -------------------------------------------------------------------------
     582             : 
     583           0 : sal_Bool SAL_CALL OStatement_Base::getMoreResults(  ) throw(SQLException, RuntimeException)
     584             : {
     585           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     586           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     587             : 
     588             : 
     589           0 :     SQLWarning  warning;
     590           0 :     sal_Bool hasResultSet = sal_False;
     591             : 
     592             :     // clear previous warnings
     593             : 
     594           0 :     clearWarnings ();
     595             : 
     596             :     // Call SQLMoreResults
     597             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     598             : 
     599             :     try {
     600           0 :         hasResultSet = N3SQLMoreResults(m_aStatementHandle) == SQL_SUCCESS;
     601             :     }
     602           0 :     catch (const SQLWarning &ex) {
     603             : 
     604             :         // Save pointer to warning and save with ResultSet
     605             :         // object once it is created.
     606             : 
     607           0 :         warning = ex;
     608             :     }
     609             : 
     610             :     // There are more results (it may not be a result set, though)
     611             : 
     612           0 :     if (hasResultSet)
     613             :     {
     614             : 
     615             :         // Now determine if there is a result set associated
     616             :         // with the SQL statement that was executed.  Get the
     617             :         // column count, and if it is zero, there is not a
     618             :         // result set.
     619             : 
     620           0 :         if (getColumnCount () == 0)
     621           0 :             hasResultSet = sal_False;
     622             :     }
     623             : 
     624             :     // Set the warning for the statement, if one was generated
     625             : 
     626           0 :     setWarning (warning);
     627             : 
     628             :     // Return the result set indicator
     629             : 
     630           0 :     return hasResultSet;
     631             : }
     632             : // -------------------------------------------------------------------------
     633             : 
     634             : // -------------------------------------------------------------------------
     635           0 : Any SAL_CALL OStatement_Base::getWarnings(  ) throw(SQLException, RuntimeException)
     636             : {
     637           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     638           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     639             : 
     640             : 
     641           0 :     return makeAny(m_aLastWarning);
     642             : }
     643             : // -------------------------------------------------------------------------
     644             : 
     645             : // -------------------------------------------------------------------------
     646           0 : void SAL_CALL OStatement_Base::clearWarnings(  ) throw(SQLException, RuntimeException)
     647             : {
     648           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     649           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     650             : 
     651             : 
     652           0 :     m_aLastWarning = SQLWarning();
     653           0 : }
     654             : // -------------------------------------------------------------------------
     655             : //------------------------------------------------------------------------------
     656           0 : sal_Int64 OStatement_Base::getQueryTimeOut() const
     657             : {
     658           0 :     return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT);
     659             : }
     660             : //------------------------------------------------------------------------------
     661           0 : sal_Int64 OStatement_Base::getMaxRows() const
     662             : {
     663           0 :     return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS);
     664             : }
     665             : //------------------------------------------------------------------------------
     666           0 : sal_Int32 OStatement_Base::getResultSetConcurrency() const
     667             : {
     668             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     669           0 :     SQLULEN nValue (getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CONCURRENCY));
     670           0 :     if(nValue == SQL_CONCUR_READ_ONLY)
     671           0 :         nValue = ResultSetConcurrency::READ_ONLY;
     672             :     else
     673           0 :         nValue = ResultSetConcurrency::UPDATABLE;
     674           0 :     return nValue;
     675             : }
     676             : //------------------------------------------------------------------------------
     677           0 : sal_Int32 OStatement_Base::getResultSetType() const
     678             : {
     679             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     680           0 :     SQLULEN nValue (getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_FORWARD_ONLY));
     681           0 :     switch(nValue)
     682             :     {
     683             :         case SQL_CURSOR_FORWARD_ONLY:
     684           0 :             nValue = ResultSetType::FORWARD_ONLY;
     685           0 :             break;
     686             :         case SQL_CURSOR_KEYSET_DRIVEN:
     687             :         case SQL_CURSOR_STATIC:
     688           0 :             nValue = ResultSetType::SCROLL_INSENSITIVE;
     689           0 :             break;
     690             :         case SQL_CURSOR_DYNAMIC:
     691           0 :             nValue = ResultSetType::SCROLL_SENSITIVE;
     692           0 :             break;
     693             :         default:
     694             :             OSL_FAIL("Unknown ODBC Cursor Type");
     695             :     }
     696             : 
     697           0 :     return nValue;
     698             : }
     699             : //------------------------------------------------------------------------------
     700           0 : sal_Int32 OStatement_Base::getFetchDirection() const
     701             : {
     702             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     703           0 :     SQLULEN nValue (getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_SCROLLABLE));
     704           0 :     switch(nValue)
     705             :     {
     706             :         case SQL_SCROLLABLE:
     707           0 :             nValue = FetchDirection::REVERSE;
     708           0 :             break;
     709             :         default:
     710           0 :             nValue = FetchDirection::FORWARD;
     711           0 :             break;
     712             :     }
     713             : 
     714           0 :     return nValue;
     715             : }
     716             : //------------------------------------------------------------------------------
     717           0 : sal_Int32 OStatement_Base::getFetchSize() const
     718             : {
     719             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     720           0 :     return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE);
     721             : }
     722             : //------------------------------------------------------------------------------
     723           0 : sal_Int64 OStatement_Base::getMaxFieldSize() const
     724             : {
     725           0 :     return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH);
     726             : }
     727             : //------------------------------------------------------------------------------
     728           0 : ::rtl::OUString OStatement_Base::getCursorName() const
     729             : {
     730             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     731             :     SQLCHAR pName[258];
     732           0 :     SQLSMALLINT nRealLen = 0;
     733           0 :     SQLRETURN nRetCode = N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen);
     734             :     OSL_UNUSED( nRetCode );
     735           0 :     return ::rtl::OUString::createFromAscii((const char*)pName);
     736             : }
     737             : //------------------------------------------------------------------------------
     738           0 : void OStatement_Base::setQueryTimeOut(sal_Int64 seconds)
     739             : {
     740             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     741           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_QUERY_TIMEOUT,seconds);
     742           0 : }
     743             : //------------------------------------------------------------------------------
     744           0 : void OStatement_Base::setMaxRows(sal_Int64 _par0)
     745             : {
     746             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     747           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_ROWS, _par0);
     748           0 : }
     749             : //------------------------------------------------------------------------------
     750           0 : void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0)
     751             : {
     752             :     SQLULEN nSet;
     753           0 :     if(_par0 == ResultSetConcurrency::READ_ONLY)
     754           0 :         nSet = SQL_CONCUR_READ_ONLY;
     755             :     else
     756           0 :         nSet = SQL_CONCUR_VALUES;
     757             : 
     758             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     759           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CONCURRENCY, nSet);
     760           0 : }
     761             : //------------------------------------------------------------------------------
     762           0 : void OStatement_Base::setResultSetType(sal_Int32 _par0)
     763             : {
     764             : 
     765             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     766           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN);
     767             : 
     768           0 :     sal_Bool bUseBookmark = isUsingBookmarks();
     769           0 :     SQLULEN nSet( SQL_UNSPECIFIED );
     770           0 :     switch(_par0)
     771             :     {
     772             :         case ResultSetType::FORWARD_ONLY:
     773           0 :             nSet =  SQL_UNSPECIFIED;
     774           0 :             break;
     775             :         case ResultSetType::SCROLL_INSENSITIVE:
     776           0 :             nSet =  SQL_INSENSITIVE;
     777           0 :             setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_KEYSET_DRIVEN);
     778           0 :             break;
     779             :         case ResultSetType::SCROLL_SENSITIVE:
     780           0 :             if(bUseBookmark)
     781             :             {
     782           0 :                 SQLUINTEGER nCurProp = getCursorProperties(SQL_CURSOR_DYNAMIC,sal_True);
     783           0 :                 if((nCurProp & SQL_CA1_BOOKMARK) != SQL_CA1_BOOKMARK) // check if bookmark for this type isn't supported
     784             :                 { // we have to test the next one
     785           0 :                     nCurProp = getCursorProperties(SQL_CURSOR_KEYSET_DRIVEN,sal_True);
     786           0 :                     sal_Bool bNotBookmarks = ((nCurProp & SQL_CA1_BOOKMARK) != SQL_CA1_BOOKMARK);
     787           0 :                     nCurProp = getCursorProperties(SQL_CURSOR_KEYSET_DRIVEN,sal_False);
     788           0 :                     nSet = SQL_CURSOR_KEYSET_DRIVEN;
     789           0 :                     if( bNotBookmarks ||
     790             :                         ((nCurProp & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS) ||
     791             :                         ((nCurProp & SQL_CA2_SENSITIVITY_ADDITIONS) != SQL_CA2_SENSITIVITY_ADDITIONS))
     792             :                     {
     793             :                         // bookmarks for keyset isn't supported so reset bookmark setting
     794           0 :                         setUsingBookmarks(sal_False);
     795           0 :                         nSet = SQL_CURSOR_DYNAMIC;
     796             :                     }
     797             :                 }
     798             :                 else
     799           0 :                     nSet = SQL_CURSOR_DYNAMIC;
     800             :             }
     801             :             else
     802           0 :                 nSet = SQL_CURSOR_DYNAMIC;
     803           0 :             if( setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE, nSet) != SQL_SUCCESS )
     804             :             {
     805           0 :                 setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_KEYSET_DRIVEN);
     806             :             }
     807           0 :             nSet =  SQL_SENSITIVE;
     808           0 :             break;
     809             :         default:
     810             :             OSL_FAIL( "OStatement_Base::setResultSetType: invalid result set type!" );
     811           0 :             break;
     812             :     }
     813             : 
     814             : 
     815           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_SENSITIVITY, nSet);
     816           0 : }
     817             : //------------------------------------------------------------------------------
     818           0 : void OStatement_Base::setEscapeProcessing( const sal_Bool _bEscapeProc )
     819             : {
     820             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     821           0 :     SQLULEN nEscapeProc( _bEscapeProc ? SQL_NOSCAN_OFF : SQL_NOSCAN_ON );
     822           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_NOSCAN, nEscapeProc);
     823           0 : }
     824             : 
     825             : //------------------------------------------------------------------------------
     826           0 : void OStatement_Base::setFetchDirection(sal_Int32 _par0)
     827             : {
     828             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     829           0 :     if(_par0 == FetchDirection::FORWARD)
     830             :     {
     831           0 :         setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_SCROLLABLE, SQL_NONSCROLLABLE);
     832             :     }
     833           0 :     else if(_par0 == FetchDirection::REVERSE)
     834             :     {
     835           0 :         setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_SCROLLABLE, SQL_SCROLLABLE);
     836             :     }
     837           0 : }
     838             : //------------------------------------------------------------------------------
     839           0 : void OStatement_Base::setFetchSize(sal_Int32 _par0)
     840             : {
     841             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     842             :     OSL_ENSURE(_par0>0,"Illegal fetch size!");
     843           0 :     if ( _par0 > 0 )
     844             :     {
     845           0 :         setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE, _par0);
     846             : 
     847           0 :         if (m_pRowStatusArray)
     848           0 :             delete[] m_pRowStatusArray;
     849           0 :         m_pRowStatusArray = new SQLUSMALLINT[_par0];
     850           0 :         setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray);
     851             :     }
     852           0 : }
     853             : //------------------------------------------------------------------------------
     854           0 : void OStatement_Base::setMaxFieldSize(sal_Int64 _par0)
     855             : {
     856             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     857           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_MAX_LENGTH, _par0);
     858           0 : }
     859             : //------------------------------------------------------------------------------
     860           0 : void OStatement_Base::setCursorName(const ::rtl::OUString &_par0)
     861             : {
     862             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     863           0 :     ::rtl::OString aName(::rtl::OUStringToOString(_par0,getOwnConnection()->getTextEncoding()));
     864           0 :     N3SQLSetCursorName(m_aStatementHandle,(SDB_ODBC_CHAR*)aName.getStr(),(SQLSMALLINT)aName.getLength());
     865           0 : }
     866             : // -------------------------------------------------------------------------
     867           0 : sal_Bool OStatement_Base::isUsingBookmarks() const
     868             : {
     869             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     870           0 :     return SQL_UB_OFF != getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, SQL_UB_OFF);
     871             : }
     872             : // -------------------------------------------------------------------------
     873           0 : sal_Bool OStatement_Base::getEscapeProcessing() const
     874             : {
     875             :     OSL_ENSURE( m_aStatementHandle, "StatementHandle is null!" );
     876           0 :     return SQL_NOSCAN_OFF == getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, SQL_NOSCAN_OFF);;
     877             : }
     878             : // -------------------------------------------------------------------------
     879           0 : void OStatement_Base::setUsingBookmarks(sal_Bool _bUseBookmark)
     880             : {
     881             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
     882           0 :     SQLULEN nValue = _bUseBookmark ? SQL_UB_VARIABLE : SQL_UB_OFF;
     883           0 :     setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, nValue);
     884           0 : }
     885             : // -------------------------------------------------------------------------
     886           0 : ::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
     887             : {
     888           0 :     Sequence< Property > aProps(10);
     889           0 :     Property* pProperties = aProps.getArray();
     890           0 :     sal_Int32 nPos = 0;
     891           0 :     DECL_PROP0(CURSORNAME,  ::rtl::OUString);
     892           0 :     DECL_BOOL_PROP0(ESCAPEPROCESSING);
     893           0 :     DECL_PROP0(FETCHDIRECTION,sal_Int32);
     894           0 :     DECL_PROP0(FETCHSIZE,   sal_Int32);
     895           0 :     DECL_PROP0(MAXFIELDSIZE,sal_Int64);
     896           0 :     DECL_PROP0(MAXROWS,     sal_Int64);
     897           0 :     DECL_PROP0(QUERYTIMEOUT,sal_Int64);
     898           0 :     DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
     899           0 :     DECL_PROP0(RESULTSETTYPE,sal_Int32);
     900           0 :     DECL_BOOL_PROP0(USEBOOKMARKS);
     901             : 
     902           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     903             : }
     904             : 
     905             : // -------------------------------------------------------------------------
     906           0 : ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
     907             : {
     908           0 :     return *const_cast<OStatement_Base*>(this)->getArrayHelper();
     909             : }
     910             : // -------------------------------------------------------------------------
     911           0 : sal_Bool OStatement_Base::convertFastPropertyValue(
     912             :                             Any & rConvertedValue,
     913             :                             Any & rOldValue,
     914             :                             sal_Int32 nHandle,
     915             :                             const Any& rValue )
     916             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
     917             : {
     918           0 :     sal_Bool bConverted = sal_False;
     919             :     try
     920             :     {
     921           0 :         switch(nHandle)
     922             :         {
     923             :             case PROPERTY_ID_QUERYTIMEOUT:
     924           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
     925           0 :                 break;
     926             : 
     927             :             case PROPERTY_ID_MAXFIELDSIZE:
     928           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
     929           0 :                 break;
     930             : 
     931             :             case PROPERTY_ID_MAXROWS:
     932           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows());
     933           0 :                 break;
     934             : 
     935             :             case PROPERTY_ID_CURSORNAME:
     936           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
     937           0 :                 break;
     938             : 
     939             :             case PROPERTY_ID_RESULTSETCONCURRENCY:
     940           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
     941           0 :                 break;
     942             : 
     943             :             case PROPERTY_ID_RESULTSETTYPE:
     944           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
     945           0 :                 break;
     946             : 
     947             :             case PROPERTY_ID_FETCHDIRECTION:
     948           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
     949           0 :                 break;
     950             : 
     951             :             case PROPERTY_ID_FETCHSIZE:
     952           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
     953           0 :                 break;
     954             : 
     955             :             case PROPERTY_ID_USEBOOKMARKS:
     956           0 :                 bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, isUsingBookmarks());
     957           0 :                 break;
     958             : 
     959             :             case PROPERTY_ID_ESCAPEPROCESSING:
     960           0 :                 bConverted = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, getEscapeProcessing() );
     961           0 :                 break;
     962             : 
     963             :         }
     964             :     }
     965           0 :     catch(const SQLException&)
     966             :     {
     967             :         //  throw Exception(e.Message,*this);
     968             :     }
     969           0 :     return bConverted;
     970             : }
     971             : // -------------------------------------------------------------------------
     972           0 : void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
     973             : {
     974             :     try
     975             :     {
     976           0 :         switch(nHandle)
     977             :         {
     978             :             case PROPERTY_ID_QUERYTIMEOUT:
     979           0 :                 setQueryTimeOut(comphelper::getINT64(rValue));
     980           0 :                 break;
     981             :             case PROPERTY_ID_MAXFIELDSIZE:
     982           0 :                 setMaxFieldSize(comphelper::getINT64(rValue));
     983           0 :                 break;
     984             :             case PROPERTY_ID_MAXROWS:
     985           0 :                 setMaxRows(comphelper::getINT64(rValue));
     986           0 :                 break;
     987             :             case PROPERTY_ID_CURSORNAME:
     988           0 :                 setCursorName(comphelper::getString(rValue));
     989           0 :                 break;
     990             :             case PROPERTY_ID_RESULTSETCONCURRENCY:
     991           0 :                 setResultSetConcurrency(comphelper::getINT32(rValue));
     992           0 :                 break;
     993             :             case PROPERTY_ID_RESULTSETTYPE:
     994           0 :                 setResultSetType(comphelper::getINT32(rValue));
     995           0 :                 break;
     996             :             case PROPERTY_ID_FETCHDIRECTION:
     997           0 :                 setFetchDirection(comphelper::getINT32(rValue));
     998           0 :                 break;
     999             :             case PROPERTY_ID_FETCHSIZE:
    1000           0 :                 setFetchSize(comphelper::getINT32(rValue));
    1001           0 :                 break;
    1002             :             case PROPERTY_ID_USEBOOKMARKS:
    1003           0 :                 setUsingBookmarks(comphelper::getBOOL(rValue));
    1004           0 :                 break;
    1005             :             case PROPERTY_ID_ESCAPEPROCESSING:
    1006           0 :                 setEscapeProcessing( ::comphelper::getBOOL( rValue ) );
    1007           0 :                 break;
    1008             :             default:
    1009             :                 OSL_FAIL( "OStatement_Base::setFastPropertyValue_NoBroadcast: what property?" );
    1010           0 :                 break;
    1011             :         }
    1012             :     }
    1013           0 :     catch(const SQLException& )
    1014             :     {
    1015             :         //  throw Exception(e.Message,*this);
    1016             :     }
    1017           0 : }
    1018             : // -------------------------------------------------------------------------
    1019           0 : void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
    1020             : {
    1021           0 :     switch(nHandle)
    1022             :     {
    1023             :         case PROPERTY_ID_QUERYTIMEOUT:
    1024           0 :             rValue <<= getQueryTimeOut();
    1025           0 :             break;
    1026             :         case PROPERTY_ID_MAXFIELDSIZE:
    1027           0 :             rValue <<= getMaxFieldSize();
    1028           0 :             break;
    1029             :         case PROPERTY_ID_MAXROWS:
    1030           0 :             rValue <<= getMaxRows();
    1031           0 :             break;
    1032             :         case PROPERTY_ID_CURSORNAME:
    1033           0 :             rValue <<= getCursorName();
    1034           0 :             break;
    1035             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
    1036           0 :             rValue <<= getResultSetConcurrency();
    1037           0 :             break;
    1038             :         case PROPERTY_ID_RESULTSETTYPE:
    1039           0 :             rValue <<= getResultSetType();
    1040           0 :             break;
    1041             :         case PROPERTY_ID_FETCHDIRECTION:
    1042           0 :             rValue <<= getFetchDirection();
    1043           0 :             break;
    1044             :         case PROPERTY_ID_FETCHSIZE:
    1045           0 :             rValue <<= getFetchSize();
    1046           0 :             break;
    1047             :         case PROPERTY_ID_USEBOOKMARKS:
    1048           0 :             rValue <<= isUsingBookmarks();
    1049           0 :             break;
    1050             :         case PROPERTY_ID_ESCAPEPROCESSING:
    1051           0 :             rValue <<= getEscapeProcessing();
    1052           0 :             break;
    1053             :         default:
    1054             :             OSL_FAIL( "OStatement_Base::getFastPropertyValue: what property?" );
    1055           0 :             break;
    1056             :     }
    1057           0 : }
    1058             : // -------------------------------------------------------------------------
    1059           0 : IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
    1060             : // -----------------------------------------------------------------------------
    1061           0 : void SAL_CALL OStatement_Base::acquire() throw()
    1062             : {
    1063           0 :     OStatement_BASE::acquire();
    1064           0 : }
    1065             : // -----------------------------------------------------------------------------
    1066           0 : void SAL_CALL OStatement_Base::release() throw()
    1067             : {
    1068           0 :     OStatement_BASE::release();
    1069           0 : }
    1070             : // -----------------------------------------------------------------------------
    1071           0 : void SAL_CALL OStatement::acquire() throw()
    1072             : {
    1073           0 :     OStatement_BASE2::acquire();
    1074           0 : }
    1075             : // -----------------------------------------------------------------------------
    1076           0 : void SAL_CALL OStatement::release() throw()
    1077             : {
    1078           0 :     OStatement_BASE2::release();
    1079           0 : }
    1080             : // -----------------------------------------------------------------------------
    1081           0 : OResultSet* OStatement_Base::createResulSet()
    1082             : {
    1083           0 :     return new OResultSet(m_aStatementHandle,this);
    1084             : }
    1085             : // -----------------------------------------------------------------------------
    1086           0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo(  ) throw(RuntimeException)
    1087             : {
    1088           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
    1089             : }
    1090             : // -----------------------------------------------------------------------------
    1091           0 : SQLUINTEGER OStatement_Base::getCursorProperties(SQLINTEGER _nCursorType,sal_Bool bFirst)
    1092             : {
    1093           0 :     SQLUINTEGER nValueLen = 0;
    1094             :     try
    1095             :     {
    1096           0 :         SQLUSMALLINT nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
    1097           0 :         if(SQL_CURSOR_KEYSET_DRIVEN == _nCursorType)
    1098           0 :             nAskFor = bFirst ? SQL_KEYSET_CURSOR_ATTRIBUTES1 : SQL_KEYSET_CURSOR_ATTRIBUTES2;
    1099           0 :         else if(SQL_CURSOR_STATIC  == _nCursorType)
    1100           0 :             nAskFor = bFirst ? SQL_STATIC_CURSOR_ATTRIBUTES1 : SQL_STATIC_CURSOR_ATTRIBUTES2;
    1101           0 :         else if(SQL_CURSOR_FORWARD_ONLY == _nCursorType)
    1102           0 :             nAskFor = bFirst ? SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 : SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
    1103           0 :         else if(SQL_CURSOR_DYNAMIC == _nCursorType)
    1104           0 :             nAskFor = bFirst ? SQL_DYNAMIC_CURSOR_ATTRIBUTES1 : SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
    1105             : 
    1106             : 
    1107           0 :         OTools::GetInfo(getOwnConnection(),getConnectionHandle(),nAskFor,nValueLen,NULL);
    1108             :     }
    1109           0 :     catch(const Exception&)
    1110             :     { // we don't want our result destroy here
    1111           0 :         nValueLen = 0;
    1112             :     }
    1113           0 :     return nValueLen;
    1114             : }
    1115             : // -----------------------------------------------------------------------------
    1116             : 
    1117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10