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

Generated by: LCOV version 1.11