LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - OStatement.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 483 0.0 %
Date: 2014-11-03 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.clear();
      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, std::exception)
     133             : {
     134           0 :     if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
     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, std::exception)
     141             : {
     142           0 :     ::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
     143           0 :                                     cppu::UnoType<XFastPropertySet>::get(),
     144           0 :                                     cppu::UnoType<XPropertySet>::get());
     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 :                         cppu::UnoType<XGeneratedResultSet>::get());
     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, std::exception)
     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 :         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, std::exception)
     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, std::exception)
     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, std::exception)
     195             : {
     196             : 
     197           0 : }
     198             : 
     199           0 : void OStatement_Base::reset()
     200             :     throw (SQLException, RuntimeException)
     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           0 : void OStatement_Base::clearMyResultSet()
     221             :     throw (SQLException, RuntimeException)
     222             : {
     223           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     224           0 :     checkDisposed(OStatement_BASE::rBHelper.bDisposed);
     225             : 
     226             :     try
     227             :     {
     228           0 :         Reference<XCloseable> xCloseable;
     229           0 :         if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
     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, (SDB_ODBC_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, (SDB_ODBC_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,(SQLCHAR*)pName,256,&nRealLen);
     733             :     OSL_UNUSED( nRetCode );
     734           0 :     return OUString::createFromAscii((const 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,(SDB_ODBC_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, ::getBooleanCppuType(), 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, ::getBooleanCppuType(), 0);
     910             : 
     911           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     912             : }
     913             : 
     914             : 
     915           0 : ::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
     916             : {
     917           0 :     return *const_cast<OStatement_Base*>(this)->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.10