LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/odbcbase - OResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 876 0.0 %
Date: 2012-12-27 Functions: 0 148 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             : #include "odbc/OResultSet.hxx"
      21             : #include "odbc/OTools.hxx"
      22             : #include "odbc/OResultSetMetaData.hxx"
      23             : #include <com/sun/star/sdbc/DataType.hpp>
      24             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      25             : #include <com/sun/star/beans/PropertyVetoException.hpp>
      26             : #include <com/sun/star/sdbcx/CompareBookmark.hpp>
      27             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      28             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      29             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      30             : #include <comphelper/property.hxx>
      31             : #include <comphelper/sequence.hxx>
      32             : #include <cppuhelper/typeprovider.hxx>
      33             : #include <comphelper/extract.hxx>
      34             : #include <com/sun/star/lang/DisposedException.hpp>
      35             : #include <comphelper/types.hxx>
      36             : #include "connectivity/dbtools.hxx"
      37             : #include "connectivity/dbexception.hxx"
      38             : #include "diagnose_ex.h"
      39             : #include <rtl/logfile.hxx>
      40             : #include <boost/static_assert.hpp>
      41             : 
      42             : #include <o3tl/compat_functional.hxx>
      43             : 
      44             : using namespace ::comphelper;
      45             : using namespace connectivity;
      46             : using namespace connectivity::odbc;
      47             : using namespace cppu;
      48             : using namespace com::sun::star::uno;
      49             : using namespace com::sun::star::lang;
      50             : using namespace com::sun::star::beans;
      51             : using namespace com::sun::star::sdbc;
      52             : using namespace com::sun::star::sdbcx;
      53             : using namespace com::sun::star::container;
      54             : using namespace com::sun::star::io;
      55             : using namespace com::sun::star::util;
      56             : 
      57             : #define ODBC_SQL_NOT_DEFINED    99UL
      58             : BOOST_STATIC_ASSERT( ODBC_SQL_NOT_DEFINED != SQL_UB_OFF );
      59             : BOOST_STATIC_ASSERT( ODBC_SQL_NOT_DEFINED != SQL_UB_ON );
      60             : BOOST_STATIC_ASSERT( ODBC_SQL_NOT_DEFINED != SQL_UB_FIXED );
      61             : BOOST_STATIC_ASSERT( ODBC_SQL_NOT_DEFINED != SQL_UB_VARIABLE );
      62             : 
      63             : namespace
      64             : {
      65             :     const SQLLEN nMaxBookmarkLen = 20;
      66             : }
      67             : 
      68             : //------------------------------------------------------------------------------
      69             : //  IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
      70           0 : ::rtl::OUString SAL_CALL OResultSet::getImplementationName(  ) throw ( RuntimeException)
      71             : {
      72           0 :     return ::rtl::OUString("com.sun.star.sdbcx.odbc.ResultSet");
      73             : }
      74             : // -------------------------------------------------------------------------
      75           0 :  Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames(  ) throw( RuntimeException)
      76             : {
      77           0 :      Sequence< ::rtl::OUString > aSupported(2);
      78           0 :     aSupported[0] = ::rtl::OUString("com.sun.star.sdbc.ResultSet");
      79           0 :     aSupported[1] = ::rtl::OUString("com.sun.star.sdbcx.ResultSet");
      80           0 :     return aSupported;
      81             : }
      82             : // -------------------------------------------------------------------------
      83           0 : sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
      84             : {
      85           0 :     Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
      86           0 :     const ::rtl::OUString* pSupported = aSupported.getConstArray();
      87           0 :     const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
      88           0 :     for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
      89             :         ;
      90             : 
      91           0 :     return pSupported != pEnd;
      92             : }
      93             : 
      94             : // -------------------------------------------------------------------------
      95           0 : OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :   OResultSet_BASE(m_aMutex)
      96             :                         ,OPropertySetHelper(OResultSet_BASE::rBHelper)
      97             :                         ,m_bFetchDataInOrder(sal_True)
      98             :                         ,m_aStatementHandle(_pStatementHandle)
      99           0 :                         ,m_aConnectionHandle(pStmt->getConnectionHandle())
     100             :                         ,m_pStatement(pStmt)
     101             :                         ,m_pSkipDeletedSet(NULL)
     102             :                         ,m_xStatement(*pStmt)
     103             :                         ,m_xMetaData(NULL)
     104             :                         ,m_pRowStatusArray( NULL )
     105           0 :                         ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
     106             :                         ,m_nRowPos(0)
     107             :                         ,m_nUseBookmarks(ODBC_SQL_NOT_DEFINED)
     108             :                         ,m_nCurrentFetchState(0)
     109             :                         ,m_bWasNull(sal_True)
     110             :                         ,m_bEOF(sal_True)
     111             :                         ,m_bLastRecord(sal_False)
     112             :                         ,m_bFreeHandle(sal_False)
     113             :                         ,m_bInserting(sal_False)
     114             :                         ,m_bRowInserted(sal_False)
     115             :                         ,m_bRowDeleted(sal_False)
     116           0 :                         ,m_bUseFetchScroll(sal_False)
     117             : {
     118           0 :     osl_atomic_increment( &m_refCount );
     119             :     try
     120             :     {
     121           0 :         m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
     122           0 :         setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray);
     123             :     }
     124           0 :     catch(const Exception&)
     125             :     { // we don't want our result destroy here
     126             :     }
     127           0 :     SQLULEN nCurType = 0;
     128             :     try
     129             :     {
     130           0 :         nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE);
     131           0 :         SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,sal_False);
     132           0 :         if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
     133             :             (nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)
     134           0 :             m_pSkipDeletedSet = new OSkipDeletedSet(this);
     135             :     }
     136           0 :     catch(const Exception&)
     137             :     { // we don't want our result destroy here
     138             :     }
     139             :     try
     140             :     {
     141           0 :         SQLUINTEGER nValueLen = 0;
     142             :         // Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms715441%28v=vs.85%29.aspx
     143             :         // LibreOffice ODBC binds columns only on update, so we don't care about SQL_GD_ANY_COLUMN / SQL_GD_BOUND
     144             :         // TODO: maybe a problem if a column is updated, then an earlier column fetched?
     145             :         //       an updated column is bound...
     146             :         // TODO: aren't we assuming SQL_GD_OUTPUT_PARAMS?
     147             :         //       If yes, we should at least OSL_ENSURE it,
     148             :         //       even better throw an exception any OUT parameter registration if !SQL_GD_OUTPUT_PARAMS.
     149             :         // If !SQL_GD_ANY_ORDER, cache the whole row so that callers can access columns in any order.
     150             :         // In other words, isolate them from ODBC restrictions.
     151             :         // TODO: we assume SQL_GD_BLOCK, unless fetchSize is 1
     152           0 :         OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_GETDATA_EXTENSIONS,nValueLen,NULL);
     153           0 :         m_bFetchDataInOrder = !((SQL_GD_ANY_ORDER & nValueLen) == SQL_GD_ANY_ORDER);
     154             :     }
     155           0 :     catch(const Exception&)
     156             :     {
     157           0 :         m_bFetchDataInOrder = sal_True;
     158             :     }
     159             :     try
     160             :     {
     161             :         // TODO: this does *not* do what it appears.
     162             :         //       We use SQLFetchScroll unconditionally in several places
     163             :         //       the *only* difference this makes is whether ::next() uses SQLFetchScroll or SQLFetch
     164             :         //       so this test seems pointless
     165           0 :         if ( getOdbcFunction(ODBC3SQLGetFunctions) )
     166             :         {
     167           0 :             SQLUSMALLINT nSupported = 0;
     168           0 :             m_bUseFetchScroll = ( N3SQLGetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 );
     169             :         }
     170             :     }
     171           0 :     catch(const Exception&)
     172             :     {
     173           0 :         m_bUseFetchScroll = sal_False;
     174             :     }
     175             : 
     176           0 :     osl_atomic_decrement( &m_refCount );
     177           0 : }
     178             : // -------------------------------------------------------------------------
     179           0 : OResultSet::~OResultSet()
     180             : {
     181           0 :     delete [] m_pRowStatusArray;
     182           0 :     delete m_pSkipDeletedSet;
     183           0 : }
     184             : // -----------------------------------------------------------------------------
     185           0 : void OResultSet::construct()
     186             : {
     187           0 :     osl_atomic_increment( &m_refCount );
     188           0 :     allocBuffer();
     189           0 :     osl_atomic_decrement( &m_refCount );
     190           0 : }
     191             : // -------------------------------------------------------------------------
     192           0 : void OResultSet::disposing(void)
     193             : {
     194           0 :     SQLRETURN nRet = N3SQLCloseCursor(m_aStatementHandle);
     195             :     OSL_UNUSED( nRet );
     196           0 :     OPropertySetHelper::disposing();
     197             : 
     198           0 :     ::osl::MutexGuard aGuard(m_aMutex);
     199           0 :     if(!m_aBindVector.empty())
     200           0 :         releaseBuffer();
     201           0 :     if(m_bFreeHandle)
     202           0 :         m_pStatement->getOwnConnection()->freeStatementHandle(m_aStatementHandle);
     203             : 
     204           0 : m_xStatement.clear();
     205           0 : m_xMetaData.clear();
     206           0 : }
     207             : // -------------------------------------------------------------------------
     208           0 : SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
     209             : {
     210             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::unbind" );
     211           0 :     SQLRETURN nRet = 0;
     212           0 :     if ( _bUnbindHandle )
     213           0 :         nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND);
     214             : 
     215           0 :     if ( m_aBindVector.size() > 1 )
     216             :     {
     217           0 :         TVoidVector::iterator pValue = m_aBindVector.begin() + 1;
     218           0 :         TVoidVector::iterator pEnd = m_aBindVector.end();
     219           0 :         for(; pValue != pEnd; ++pValue)
     220             :         {
     221           0 :             switch (pValue->second)
     222             :             {
     223             :                 case DataType::CHAR:
     224             :                 case DataType::VARCHAR:
     225           0 :                     delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
     226           0 :                     break;
     227             :                 case DataType::BIGINT:
     228           0 :                     delete static_cast< sal_Int64* >(reinterpret_cast< void * >(pValue->first));
     229           0 :                     break;
     230             :                 case DataType::DECIMAL:
     231             :                 case DataType::NUMERIC:
     232           0 :                     delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
     233           0 :                     break;
     234             :                 case DataType::REAL:
     235             :                 case DataType::DOUBLE:
     236           0 :                     delete static_cast< double* >(reinterpret_cast< void * >(pValue->first));
     237           0 :                     break;
     238             :                 case DataType::LONGVARCHAR:
     239             :                 case DataType::CLOB:
     240           0 :                     delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
     241           0 :                     break;
     242             :                 case DataType::LONGVARBINARY:
     243             :                 case DataType::BLOB:
     244           0 :                     delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
     245           0 :                     break;
     246             :                 case DataType::DATE:
     247           0 :                     delete static_cast< DATE_STRUCT* >(reinterpret_cast< void * >(pValue->first));
     248           0 :                     break;
     249             :                 case DataType::TIME:
     250           0 :                     delete static_cast< TIME_STRUCT* >(reinterpret_cast< void * >(pValue->first));
     251           0 :                     break;
     252             :                 case DataType::TIMESTAMP:
     253           0 :                     delete static_cast< TIMESTAMP_STRUCT* >(reinterpret_cast< void * >(pValue->first));
     254           0 :                     break;
     255             :                 case DataType::BIT:
     256             :                 case DataType::TINYINT:
     257           0 :                     delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
     258           0 :                     break;
     259             :                 case DataType::SMALLINT:
     260           0 :                     delete static_cast< sal_Int16* >(reinterpret_cast< void * >(pValue->first));
     261           0 :                     break;
     262             :                 case DataType::INTEGER:
     263           0 :                     delete static_cast< sal_Int32* >(reinterpret_cast< void * >(pValue->first));
     264           0 :                     break;
     265             :                 case DataType::FLOAT:
     266           0 :                     delete static_cast< float* >(reinterpret_cast< void * >(pValue->first));
     267           0 :                     break;
     268             :                 case DataType::BINARY:
     269             :                 case DataType::VARBINARY:
     270           0 :                     delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
     271           0 :                     break;
     272             :             }
     273             :         }
     274           0 :         m_aBindVector.clear();
     275           0 :         m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
     276             :     }
     277           0 :     return nRet;
     278             : }
     279             : // -------------------------------------------------------------------------
     280           0 : TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)
     281             : {
     282             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBindColumn" );
     283           0 :     TVoidPtr aPair;
     284           0 :     switch (_nType)
     285             :     {
     286             :         case DataType::CHAR:
     287             :         case DataType::VARCHAR:
     288           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
     289           0 :             break;
     290             :         case DataType::BIGINT:
     291           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int64(0)),_nType);
     292           0 :             break;
     293             :         case DataType::DECIMAL:
     294             :         case DataType::NUMERIC:
     295           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
     296           0 :             break;
     297             :         case DataType::REAL:
     298             :         case DataType::DOUBLE:
     299           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType);
     300           0 :             break;
     301             :         case DataType::LONGVARCHAR:
     302             :         case DataType::CLOB:
     303           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType);  // only for finding
     304           0 :             break;
     305             :         case DataType::LONGVARBINARY:
     306             :         case DataType::BLOB:
     307           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType);  // only for finding
     308           0 :             break;
     309             :         case DataType::DATE:
     310           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new DATE_STRUCT),_nType);
     311           0 :             break;
     312             :         case DataType::TIME:
     313           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIME_STRUCT),_nType);
     314           0 :             break;
     315             :         case DataType::TIMESTAMP:
     316           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIMESTAMP_STRUCT),_nType);
     317           0 :             break;
     318             :         case DataType::BIT:
     319             :         case DataType::TINYINT:
     320           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8(0)),_nType);
     321           0 :             break;
     322             :         case DataType::SMALLINT:
     323           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int16(0)),_nType);
     324           0 :             break;
     325             :         case DataType::INTEGER:
     326           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int32(0)),_nType);
     327           0 :             break;
     328             :         case DataType::FLOAT:
     329           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new float(0)),_nType);
     330           0 :             break;
     331             :         case DataType::BINARY:
     332             :         case DataType::VARBINARY:
     333           0 :             aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8[m_aRow[_nColumnIndex].getSequence().getLength()]),_nType);
     334           0 :             break;
     335             :         default:
     336             :             OSL_FAIL("Unknown type");
     337           0 :             aPair = TVoidPtr(0,_nType);
     338             :     }
     339           0 :     return aPair;
     340             : }
     341             : // -------------------------------------------------------------------------
     342           0 : void OResultSet::allocBuffer()
     343             : {
     344             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBuffer" );
     345           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     346           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     347             : 
     348           0 :     m_aBindVector.reserve(nLen+1);
     349           0 :     m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
     350           0 :     m_aRow.resize(nLen+1);
     351             : 
     352           0 :     m_aRow[0].setTypeKind(DataType::VARBINARY);
     353           0 :     m_aRow[0].setBound( false );
     354             : 
     355           0 :     for(sal_Int32 i = 1;i<=nLen;++i)
     356             :     {
     357           0 :         sal_Int32 nType = xMeta->getColumnType(i);
     358           0 :         m_aRow[i].setTypeKind( nType );
     359           0 :         m_aRow[i].setBound( false );
     360             :     }
     361           0 :     m_aLengthVector.resize(nLen + 1);
     362           0 : }
     363             : // -------------------------------------------------------------------------
     364           0 : void OResultSet::releaseBuffer()
     365             : {
     366             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::releaseBuffer" );
     367           0 :     unbind(sal_False);
     368           0 :     m_aLengthVector.clear();
     369           0 : }
     370             : // -------------------------------------------------------------------------
     371           0 : Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
     372             : {
     373           0 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     374           0 :     return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
     375             : }
     376             : // -------------------------------------------------------------------------
     377           0 :  Sequence<  Type > SAL_CALL OResultSet::getTypes(  ) throw( RuntimeException)
     378             : {
     379           0 :     OTypeCollection aTypes( ::getCppuType( (const  Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
     380           0 :                                                 ::getCppuType( (const  Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
     381           0 :                                                 ::getCppuType( (const  Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
     382             : 
     383           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
     384             : }
     385             : // -------------------------------------------------------------------------
     386             : 
     387           0 : sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
     388             : {
     389             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
     390           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     391             : 
     392             : 
     393           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     394             : 
     395           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     396           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     397           0 :     sal_Int32 i = 1;
     398           0 :     for(;i<=nLen;++i)
     399           0 :         if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
     400           0 :                 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
     401           0 :             break;
     402           0 :     return i;
     403             : }
     404             : // -------------------------------------------------------------------------
     405           0 : void OResultSet::ensureCacheForColumn(sal_Int32 columnIndex)
     406             : {
     407             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "lionel@mamane.lu", "OResultSet::ensureCacheForColumn" );
     408             : 
     409             :     assert(columnIndex >= 0);
     410             : 
     411           0 :     const TDataRow::size_type oldCacheSize = m_aRow.size();
     412           0 :     const TDataRow::size_type uColumnIndex = static_cast<TDataRow::size_type>(columnIndex);
     413             : 
     414           0 :     if (oldCacheSize > uColumnIndex)
     415             :         // nothing to do
     416           0 :         return;
     417             : 
     418           0 :     m_aRow.resize(columnIndex + 1);
     419           0 :     TDataRow::iterator i (m_aRow.begin() + uColumnIndex);
     420           0 :     const TDataRow::const_iterator end(m_aRow.end());
     421           0 :     for (; i != end; ++i)
     422             :     {
     423           0 :         i->setBound(false);
     424             :     }
     425             : }
     426           0 : void OResultSet::invalidateCache()
     427             : {
     428           0 :     const TDataRow::const_iterator end = m_aRow.end();
     429           0 :     for(TDataRow::iterator i=m_aRow.begin(); i!=end; ++i)
     430             :     {
     431           0 :         i->setBound(false);
     432             :     }
     433           0 : }
     434             : // -------------------------------------------------------------------------
     435           0 : Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     436             : {
     437           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     438           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     439             : 
     440           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
     441             : 
     442           0 :     return NULL;
     443             : }
     444             : // -------------------------------------------------------------------------
     445           0 : Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     446             : {
     447           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     448           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     449             : 
     450           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
     451             : 
     452           0 :     return NULL;
     453             : }
     454             : // -----------------------------------------------------------------------------
     455           0 : template < typename T > T OResultSet::impl_getValue( const sal_Int32 _nColumnIndex, SQLSMALLINT nType )
     456             : {
     457             :     T val;
     458             : 
     459           0 :     OTools::getValue(m_pStatement->getOwnConnection(), m_aStatementHandle, _nColumnIndex, nType, m_bWasNull, **this, &val, sizeof(val));
     460             : 
     461           0 :     return val;
     462             : }
     463             : // -------------------------------------------------------------------------
     464             : // this function exists for the implicit conversion to sal_Bool (compared to a direct call to impl_getValue)
     465           0 : sal_Bool OResultSet::impl_getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     466             : {
     467           0 :     return impl_getValue<sal_Int8>(columnIndex, SQL_C_BIT);
     468             : }
     469             : // -------------------------------------------------------------------------
     470           0 : template < typename T > T OResultSet::getValue( sal_Int32 columnIndex )
     471             : {
     472           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     473           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     474           0 :     fillColumn(columnIndex);
     475           0 :     m_bWasNull = m_aRow[columnIndex].isNull();
     476           0 :     return m_aRow[columnIndex];
     477             : }
     478           0 : sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     479             : {
     480           0 :     return getValue<sal_Bool>( columnIndex );
     481             : }
     482             : // -------------------------------------------------------------------------
     483           0 : sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     484             : {
     485           0 :     return getValue<sal_Int8>( columnIndex );
     486             : }
     487             : // -------------------------------------------------------------------------
     488             : 
     489           0 : Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     490             : {
     491           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     492           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     493           0 :     fillColumn(columnIndex);
     494           0 :     m_bWasNull = m_aRow[columnIndex].isNull();
     495             : 
     496           0 :     Sequence< sal_Int8 > nRet;
     497           0 :     switch(m_aRow[columnIndex].getTypeKind())
     498             :     {
     499             :     case DataType::BINARY:
     500             :     case DataType::VARBINARY:
     501             :     case DataType::LONGVARBINARY:
     502           0 :         nRet = m_aRow[columnIndex];
     503           0 :         break;
     504             :     default:
     505             :     {
     506           0 :         rtl::OUString sRet;
     507           0 :         sRet = m_aRow[columnIndex].getString();
     508           0 :         nRet = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(sRet.getStr()),sizeof(sal_Unicode)*sRet.getLength());
     509             :     }
     510             :     }
     511           0 :     return nRet;
     512             : }
     513           0 : Sequence< sal_Int8 > OResultSet::impl_getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     514             : {
     515           0 :     const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
     516             : 
     517           0 :     switch(nColumnType)
     518             :     {
     519             :     case SQL_WVARCHAR:
     520             :     case SQL_WCHAR:
     521             :     case SQL_WLONGVARCHAR:
     522             :     case SQL_VARCHAR:
     523             :     case SQL_CHAR:
     524             :     case SQL_LONGVARCHAR:
     525             :     {
     526           0 :         rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
     527           0 :         return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
     528             :     }
     529             :     default:
     530           0 :         return OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
     531             :     }
     532             : }
     533             : // -------------------------------------------------------------------------
     534           0 : Date OResultSet::impl_getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     535             : {
     536             :     DATE_STRUCT aDate = impl_getValue< DATE_STRUCT> ( columnIndex,
     537           0 :                                                       m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE  );
     538             : 
     539           0 :     return Date(aDate.day, aDate.month, aDate.year);
     540             : }
     541             : // -------------------------------------------------------------------------
     542           0 : Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     543             : {
     544           0 :     return getValue<Date>( columnIndex );
     545             : }
     546             : // -------------------------------------------------------------------------
     547             : 
     548           0 : double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     549             : {
     550           0 :     return getValue<double>( columnIndex );
     551             : }
     552             : // -------------------------------------------------------------------------
     553             : 
     554           0 : float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     555             : {
     556           0 :     return getValue<float>( columnIndex );
     557             : }
     558             : // -------------------------------------------------------------------------
     559           0 : sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     560             : {
     561           0 :     return getValue<sal_Int16>( columnIndex );
     562             : }
     563             : // -------------------------------------------------------------------------
     564           0 : sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     565             : {
     566           0 :     return getValue<sal_Int32>( columnIndex );
     567             : }
     568             : // -------------------------------------------------------------------------
     569           0 : sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     570             : {
     571           0 :     return getValue<sal_Int64>( columnIndex );
     572             : }
     573           0 : sal_Int64 OResultSet::impl_getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     574             : {
     575             :     try
     576             :     {
     577           0 :         return impl_getValue<sal_Int64>(columnIndex, SQL_C_SBIGINT);
     578             :     }
     579           0 :     catch(const SQLException&)
     580             :     {
     581           0 :         return getString(columnIndex).toInt64();
     582             :     }
     583             : }
     584             : // -------------------------------------------------------------------------
     585           0 : sal_Int32 SAL_CALL OResultSet::getRow(  ) throw(SQLException, RuntimeException)
     586             : {
     587           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     588           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     589             : 
     590           0 :     return m_pSkipDeletedSet ? m_pSkipDeletedSet->getMappedPosition(getDriverPos()) : getDriverPos();
     591             : }
     592             : // -------------------------------------------------------------------------
     593           0 : Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData(  ) throw(SQLException, RuntimeException)
     594             : {
     595             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
     596           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     597           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     598             : 
     599             : 
     600           0 :     if(!m_xMetaData.is())
     601           0 :         m_xMetaData = new OResultSetMetaData(m_pStatement->getOwnConnection(),m_aStatementHandle);
     602           0 :     return m_xMetaData;
     603             : }
     604             : // -------------------------------------------------------------------------
     605           0 : Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     606             : {
     607           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
     608           0 :     return NULL;
     609             : }
     610             : 
     611             : // -------------------------------------------------------------------------
     612             : 
     613           0 : Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     614             : {
     615           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
     616           0 :     return NULL;
     617             : }
     618             : // -------------------------------------------------------------------------
     619           0 : Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     620             : {
     621           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
     622           0 :     return NULL;
     623             : }
     624             : // -------------------------------------------------------------------------
     625             : 
     626           0 : Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
     627             : {
     628           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
     629           0 :     return NULL;
     630             : }
     631             : // -------------------------------------------------------------------------
     632             : 
     633           0 : Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
     634             : {
     635           0 :     return getValue<ORowSetValue>( columnIndex ).makeAny();
     636             : }
     637             : // -------------------------------------------------------------------------
     638           0 : ::rtl::OUString OResultSet::impl_getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     639             : {
     640           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     641           0 :     const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
     642           0 :     return OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
     643             : }
     644           0 : ::rtl::OUString OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     645             : {
     646           0 :     return getValue<rtl::OUString>( columnIndex );
     647             : }
     648             : // -------------------------------------------------------------------------
     649           0 : Time OResultSet::impl_getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     650             : {
     651             :     TIME_STRUCT aTime = impl_getValue< TIME_STRUCT > ( columnIndex,
     652           0 :                                                       m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME );
     653             : 
     654           0 :     return Time(0,aTime.second,aTime.minute,aTime.hour);
     655             : }
     656           0 : Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     657             : {
     658           0 :     return getValue<Time>( columnIndex );
     659             : }
     660             : // -------------------------------------------------------------------------
     661           0 : DateTime OResultSet::impl_getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     662             : {
     663             :     TIMESTAMP_STRUCT aTime = impl_getValue< TIMESTAMP_STRUCT > ( columnIndex,
     664           0 :                                                                  m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP );
     665             : 
     666             :     return DateTime(static_cast<sal_uInt16>(aTime.fraction/ODBC_FRACTION_UNITS_PER_HSECOND),
     667             :                     aTime.second,
     668             :                     aTime.minute,
     669             :                     aTime.hour,
     670             :                     aTime.day,
     671             :                     aTime.month,
     672           0 :                     aTime.year);
     673             : }
     674           0 : DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
     675             : {
     676           0 :     return getValue<DateTime>( columnIndex );
     677             : }
     678             : // -------------------------------------------------------------------------
     679           0 : sal_Bool SAL_CALL OResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException)
     680             : {
     681           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     682           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     683           0 :     return m_nRowPos == 0;
     684             : }
     685             : // -------------------------------------------------------------------------
     686           0 : sal_Bool SAL_CALL OResultSet::isAfterLast(  ) throw(SQLException, RuntimeException)
     687             : {
     688           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     689           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     690             : 
     691           0 :     return m_nRowPos != 0 && m_nCurrentFetchState == SQL_NO_DATA;
     692             : }
     693             : // -------------------------------------------------------------------------
     694           0 : sal_Bool SAL_CALL OResultSet::isFirst(  ) throw(SQLException, RuntimeException)
     695             : {
     696           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     697           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     698             : 
     699           0 :     return m_nRowPos == 1;
     700             : }
     701             : // -------------------------------------------------------------------------
     702           0 : sal_Bool SAL_CALL OResultSet::isLast(  ) throw(SQLException, RuntimeException)
     703             : {
     704           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     705           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     706             : 
     707             : 
     708           0 :     return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
     709             : }
     710             : // -------------------------------------------------------------------------
     711           0 : void SAL_CALL OResultSet::beforeFirst(  ) throw(SQLException, RuntimeException)
     712             : {
     713             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
     714           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     715           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     716             : 
     717             : 
     718           0 :     if(first())
     719           0 :         previous();
     720           0 :     m_nCurrentFetchState = SQL_SUCCESS;
     721           0 : }
     722             : // -------------------------------------------------------------------------
     723           0 : void SAL_CALL OResultSet::afterLast(  ) throw(SQLException, RuntimeException)
     724             : {
     725             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
     726           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     727           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     728             : 
     729           0 :     if(last())
     730           0 :         next();
     731           0 :     m_bEOF = sal_True;
     732           0 : }
     733             : // -------------------------------------------------------------------------
     734             : 
     735           0 : void SAL_CALL OResultSet::close(  ) throw(SQLException, RuntimeException)
     736             : {
     737             :     {
     738           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     739           0 :         checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     740             : 
     741             :     }
     742           0 :     dispose();
     743           0 : }
     744             : // -------------------------------------------------------------------------
     745             : 
     746           0 : sal_Bool SAL_CALL OResultSet::first(  ) throw(SQLException, RuntimeException)
     747             : {
     748             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::first" );
     749           0 :     return moveImpl(IResultSetHelper::FIRST,0,sal_True);
     750             : }
     751             : // -------------------------------------------------------------------------
     752             : 
     753           0 : sal_Bool SAL_CALL OResultSet::last(  ) throw(SQLException, RuntimeException)
     754             : {
     755             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::last" );
     756           0 :     return moveImpl(IResultSetHelper::LAST,0,sal_True);
     757             : }
     758             : // -------------------------------------------------------------------------
     759           0 : sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
     760             : {
     761             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
     762           0 :     return moveImpl(IResultSetHelper::ABSOLUTE,row,sal_True);
     763             : }
     764             : // -------------------------------------------------------------------------
     765           0 : sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
     766             : {
     767             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::relative" );
     768           0 :     return moveImpl(IResultSetHelper::RELATIVE,row,sal_True);
     769             : }
     770             : // -------------------------------------------------------------------------
     771           0 : sal_Bool SAL_CALL OResultSet::previous(  ) throw(SQLException, RuntimeException)
     772             : {
     773             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::previous" );
     774           0 :     return moveImpl(IResultSetHelper::PRIOR,0,sal_True);
     775             : }
     776             : // -------------------------------------------------------------------------
     777           0 : Reference< XInterface > SAL_CALL OResultSet::getStatement(  ) throw(SQLException, RuntimeException)
     778             : {
     779           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     780           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     781           0 :     return m_xStatement;
     782             : }
     783             : // -------------------------------------------------------------------------
     784             : 
     785           0 : sal_Bool SAL_CALL OResultSet::rowDeleted() throw(SQLException, RuntimeException)
     786             : {
     787             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
     788           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     789           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     790             : 
     791           0 :     sal_Bool bRet = m_bRowDeleted;
     792           0 :     m_bRowDeleted = sal_False;
     793             : 
     794           0 :     return bRet;
     795             : }
     796             : // -------------------------------------------------------------------------
     797           0 : sal_Bool SAL_CALL OResultSet::rowInserted(  ) throw(SQLException, RuntimeException)
     798             : {
     799             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
     800           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     801           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     802             : 
     803           0 :     sal_Bool bInserted = m_bRowInserted;
     804           0 :     m_bRowInserted = sal_False;
     805             : 
     806           0 :     return bInserted;
     807             : }
     808             : // -------------------------------------------------------------------------
     809           0 : sal_Bool SAL_CALL OResultSet::rowUpdated(  ) throw(SQLException, RuntimeException)
     810             : {
     811             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
     812           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     813           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     814             : 
     815             : 
     816           0 :     return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
     817             : }
     818             : // -------------------------------------------------------------------------
     819             : 
     820           0 : sal_Bool SAL_CALL OResultSet::next(  ) throw(SQLException, RuntimeException)
     821             : {
     822             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::next" );
     823           0 :     return moveImpl(IResultSetHelper::NEXT,1,sal_True);
     824             : }
     825             : // -------------------------------------------------------------------------
     826             : 
     827           0 : sal_Bool SAL_CALL OResultSet::wasNull(  ) throw(SQLException, RuntimeException)
     828             : {
     829             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
     830           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     831           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     832             : 
     833           0 :     return m_bWasNull;
     834             : }
     835             : // -------------------------------------------------------------------------
     836             : 
     837           0 : void SAL_CALL OResultSet::cancel(  ) throw(RuntimeException)
     838             : {
     839           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     840           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     841             : 
     842             : 
     843           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     844           0 : }
     845             : // -------------------------------------------------------------------------
     846           0 : void SAL_CALL OResultSet::clearWarnings(  ) throw(SQLException, RuntimeException)
     847             : {
     848           0 : }
     849             : // -------------------------------------------------------------------------
     850           0 : Any SAL_CALL OResultSet::getWarnings(  ) throw(SQLException, RuntimeException)
     851             : {
     852           0 :     return Any();
     853             : }
     854             : // -------------------------------------------------------------------------
     855           0 : void SAL_CALL OResultSet::insertRow(  ) throw(SQLException, RuntimeException)
     856             : {
     857             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
     858           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     859           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     860             : 
     861             : 
     862           0 :     SQLLEN nRealLen = 0;
     863           0 :     Sequence<sal_Int8> aBookmark(nMaxBookmarkLen);
     864             :     BOOST_STATIC_ASSERT(static_cast<size_t>(nMaxBookmarkLen) >= sizeof(SQLLEN));
     865             : 
     866           0 :     SQLRETURN nRet = N3SQLBindCol(m_aStatementHandle,
     867             :                                 0,
     868             :                                 SQL_C_VARBOOKMARK,
     869             :                                 aBookmark.getArray(),
     870             :                                 nMaxBookmarkLen,
     871             :                                 &nRealLen
     872             :                                 );
     873             : 
     874           0 :     aBookmark.realloc(nRealLen);
     875           0 :     sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
     876           0 :     if ( bPositionByBookmark )
     877             :     {
     878           0 :         nRet = N3SQLBulkOperations( m_aStatementHandle, SQL_ADD );
     879           0 :         fillNeededData( nRet );
     880             :     }
     881             :     else
     882             :     {
     883           0 :         if(isBeforeFirst())
     884           0 :             next(); // must be done
     885           0 :         nRet = N3SQLSetPos( m_aStatementHandle, 1, SQL_ADD, SQL_LOCK_NO_CHANGE );
     886           0 :         fillNeededData( nRet );
     887             :     }
     888             :     try
     889             :     {
     890           0 :         OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     891             :     }
     892           0 :     catch(const SQLException&)
     893             :     {
     894           0 :         nRet = unbind();
     895           0 :         throw;
     896             :     }
     897             : 
     898             : 
     899           0 :     if ( bPositionByBookmark )
     900             :     {
     901           0 :         setStmtOption<SQLLEN*, SQL_IS_POINTER>(SQL_ATTR_FETCH_BOOKMARK_PTR, reinterpret_cast<SQLLEN*>(aBookmark.getArray()));
     902             : 
     903           0 :         nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
     904             :     }
     905             :     else
     906           0 :         nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); // OJ 06.03.2004
     907             :     // sometimes we got an error but we are not interested in anymore #106047# OJ
     908             :     //  OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     909           0 :     nRet = unbind();
     910           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     911             : 
     912           0 :     if(m_pSkipDeletedSet)
     913             :     {
     914           0 :         if(moveToBookmark(makeAny(aBookmark)))
     915             :         {
     916           0 :             sal_Int32 nRowPos = getDriverPos();
     917           0 :             if ( -1 == m_nRowPos )
     918             :             {
     919           0 :                 nRowPos = m_aPosToBookmarks.size() + 1;
     920             :             }
     921           0 :             if ( nRowPos == m_nRowPos )
     922           0 :                 ++nRowPos;
     923           0 :             m_nRowPos = nRowPos;
     924           0 :             m_pSkipDeletedSet->insertNewPosition(nRowPos);
     925           0 :             m_aPosToBookmarks[aBookmark] = nRowPos;
     926             :         }
     927             :     }
     928           0 :     m_bRowInserted = sal_True;
     929             : 
     930           0 : }
     931             : // -------------------------------------------------------------------------
     932           0 : void SAL_CALL OResultSet::updateRow(  ) throw(SQLException, RuntimeException)
     933             : {
     934             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
     935           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     936           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
     937             : 
     938             :     SQLRETURN nRet;
     939             : 
     940           0 :     sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
     941           0 :     Sequence<sal_Int8> aBookmark(nMaxBookmarkLen);
     942           0 :     if ( bPositionByBookmark )
     943             :     {
     944           0 :         SQLLEN nRealLen = 0;
     945           0 :         nRet = N3SQLBindCol(m_aStatementHandle,
     946             :                             0,
     947             :                             SQL_C_VARBOOKMARK,
     948             :                             aBookmark.getArray(),
     949             :                             aBookmark.getLength(),
     950             :                             &nRealLen
     951           0 :                             );
     952           0 :         fillNeededData(nRet = N3SQLBulkOperations(m_aStatementHandle, SQL_UPDATE_BY_BOOKMARK));
     953           0 :         aBookmark.realloc(nRealLen);
     954           0 :         m_aRow[0]=aBookmark;
     955           0 :         m_aRow[0].setBound(true);
     956             :     }
     957             :     else
     958           0 :         fillNeededData(nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE));
     959           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     960             :     // now unbind all columns so we can fetch all columns again with SQLGetData
     961           0 :     nRet = unbind();
     962           0 :     OSL_ENSURE(nRet == SQL_SUCCESS,"Could not unbind the columns!");
     963           0 : }
     964             : // -------------------------------------------------------------------------
     965           0 : void SAL_CALL OResultSet::deleteRow(  ) throw(SQLException, RuntimeException)
     966             : {
     967             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
     968           0 :     SQLRETURN nRet = SQL_SUCCESS;
     969           0 :     sal_Int32 nPos = getDriverPos();
     970           0 :     nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE);
     971           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     972             : 
     973           0 :     m_bRowDeleted = ( m_pRowStatusArray[0] == SQL_ROW_DELETED );
     974           0 :     if ( m_bRowDeleted )
     975             :     {
     976           0 :         TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
     977           0 :         TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
     978           0 :         for (; aIter != aEnd; ++aIter)
     979             :         {
     980           0 :             if ( aIter->second == nPos )
     981             :             {
     982           0 :                 m_aPosToBookmarks.erase(aIter);
     983           0 :                 break;
     984             :             }
     985             :         }
     986             :     }
     987           0 :     if ( m_pSkipDeletedSet )
     988           0 :         m_pSkipDeletedSet->deletePosition(nPos);
     989           0 : }
     990             : // -------------------------------------------------------------------------
     991             : 
     992           0 : void SAL_CALL OResultSet::cancelRowUpdates(  ) throw(SQLException, RuntimeException)
     993             : {
     994           0 : }
     995             : // -------------------------------------------------------------------------
     996             : 
     997           0 : void SAL_CALL OResultSet::moveToInsertRow(  ) throw(SQLException, RuntimeException)
     998             : {
     999             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
    1000           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1001           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1002             : 
    1003             : 
    1004           0 :     invalidateCache();
    1005             :     // first unbound all columns
    1006           0 :     OSL_VERIFY_EQUALS( unbind(), SQL_SUCCESS, "Could not unbind columns!" );
    1007             :     //  SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER);
    1008           0 :     m_bInserting = sal_True;
    1009           0 : }
    1010             : // -------------------------------------------------------------------------
    1011             : 
    1012           0 : void SAL_CALL OResultSet::moveToCurrentRow(  ) throw(SQLException, RuntimeException)
    1013             : {
    1014           0 :     invalidateCache();
    1015           0 : }
    1016             : // -------------------------------------------------------------------------
    1017           0 : void OResultSet::updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void* _pValue) throw(SQLException, RuntimeException)
    1018             : {
    1019             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
    1020           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1021           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1022             : 
    1023           0 :     m_aBindVector.push_back(allocBindColumn(OTools::MapOdbcType2Jdbc(_nType),columnIndex));
    1024           0 :     void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
    1025             :     OSL_ENSURE(pData != NULL,"Data for update is NULL!");
    1026             :     OTools::bindValue(  m_pStatement->getOwnConnection(),
    1027             :                         m_aStatementHandle,
    1028             :                         columnIndex,
    1029             :                         _nType,
    1030             :                         0,
    1031             :                         _pValue,
    1032             :                         pData,
    1033           0 :                         &m_aLengthVector[columnIndex],
    1034             :                         **this,
    1035             :                         m_nTextEncoding,
    1036           0 :                         m_pStatement->getOwnConnection()->useOldDateFormat());
    1037           0 : }
    1038             : // -----------------------------------------------------------------------------
    1039           0 : void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
    1040             : {
    1041           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1042           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1043             : 
    1044           0 :     m_aBindVector.push_back(allocBindColumn(DataType::CHAR,columnIndex));
    1045           0 :     void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
    1046           0 :     OTools::bindValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_CHAR,0,(sal_Int8*)NULL,pData,&m_aLengthVector[columnIndex],**this,m_nTextEncoding,m_pStatement->getOwnConnection()->useOldDateFormat());
    1047           0 : }
    1048             : // -------------------------------------------------------------------------
    1049             : 
    1050           0 : void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
    1051             : {
    1052           0 :     updateValue(columnIndex,SQL_BIT,&x);
    1053           0 : }
    1054             : // -------------------------------------------------------------------------
    1055           0 : void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
    1056             : {
    1057           0 :     updateValue(columnIndex,SQL_CHAR,&x);
    1058           0 : }
    1059             : // -------------------------------------------------------------------------
    1060             : 
    1061           0 : void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
    1062             : {
    1063           0 :     updateValue(columnIndex,SQL_TINYINT,&x);
    1064           0 : }
    1065             : // -------------------------------------------------------------------------
    1066           0 : void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
    1067             : {
    1068           0 :     updateValue(columnIndex,SQL_INTEGER,&x);
    1069           0 : }
    1070             : // -------------------------------------------------------------------------
    1071           0 : void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
    1072             : {
    1073           0 :     ::dbtools::throwFunctionNotSupportedException( "XRowUpdate::updateLong", *this );
    1074           0 : }
    1075             : // -----------------------------------------------------------------------
    1076           0 : void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
    1077             : {
    1078           0 :     updateValue(columnIndex,SQL_REAL,&x);
    1079           0 : }
    1080             : // -------------------------------------------------------------------------
    1081             : 
    1082           0 : void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
    1083             : {
    1084           0 :     updateValue(columnIndex,SQL_DOUBLE,&x);
    1085           0 : }
    1086             : // -------------------------------------------------------------------------
    1087           0 : void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
    1088             : {
    1089           0 :     sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
    1090           0 :     SQLSMALLINT nOdbcType = OTools::jdbcTypeToOdbc(nType);
    1091           0 :     m_aRow[columnIndex] = x;
    1092           0 :     m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarchar will be recognized by fillNeededData
    1093           0 :     m_aRow[columnIndex].setBound(true);
    1094           0 :     updateValue(columnIndex,nOdbcType,(void*)&x);
    1095           0 : }
    1096             : // -------------------------------------------------------------------------
    1097           0 : void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
    1098             : {
    1099           0 :     sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
    1100           0 :     SQLSMALLINT nOdbcType = OTools::jdbcTypeToOdbc(nType);
    1101           0 :     m_aRow[columnIndex] = x;
    1102           0 :     m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarbinary will be recognized by fillNeededData
    1103           0 :     m_aRow[columnIndex].setBound(true);
    1104           0 :     updateValue(columnIndex,nOdbcType,(void*)&x);
    1105           0 : }
    1106             : // -------------------------------------------------------------------------
    1107           0 : void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) throw(SQLException, RuntimeException)
    1108             : {
    1109           0 :     DATE_STRUCT aVal = OTools::DateToOdbcDate(x);
    1110           0 :     updateValue(columnIndex,SQL_DATE,&aVal);
    1111           0 : }
    1112             : // -------------------------------------------------------------------------
    1113             : 
    1114           0 : void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) throw(SQLException, RuntimeException)
    1115             : {
    1116           0 :     TIME_STRUCT aVal = OTools::TimeToOdbcTime(x);
    1117           0 :     updateValue(columnIndex,SQL_TIME,&aVal);
    1118           0 : }
    1119             : // -------------------------------------------------------------------------
    1120             : 
    1121           0 : void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x ) throw(SQLException, RuntimeException)
    1122             : {
    1123           0 :     TIMESTAMP_STRUCT aVal = OTools::DateTimeToTimestamp(x);
    1124           0 :     updateValue(columnIndex,SQL_TIMESTAMP,&aVal);
    1125           0 : }
    1126             : // -------------------------------------------------------------------------
    1127             : 
    1128           0 : void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
    1129             : {
    1130           0 :     if(!x.is())
    1131           0 :         ::dbtools::throwFunctionSequenceException(*this);
    1132             : 
    1133           0 :     Sequence<sal_Int8> aSeq;
    1134           0 :     x->readBytes(aSeq,length);
    1135           0 :     updateBytes(columnIndex,aSeq);
    1136           0 : }
    1137             : // -------------------------------------------------------------------------
    1138           0 : void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
    1139             : {
    1140           0 :     updateBinaryStream(columnIndex,x,length);
    1141           0 : }
    1142             : // -------------------------------------------------------------------------
    1143           0 : void SAL_CALL OResultSet::refreshRow(  ) throw(SQLException, RuntimeException)
    1144             : {
    1145             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
    1146           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1147           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1148             : 
    1149             : 
    1150             :     //  SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE);
    1151           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0);
    1152           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1153           0 : }
    1154             : // -------------------------------------------------------------------------
    1155           0 : void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
    1156             : {
    1157           0 :     if (!::dbtools::implUpdateObject(this, columnIndex, x))
    1158           0 :         throw SQLException();
    1159           0 : }
    1160             : // -------------------------------------------------------------------------
    1161             : 
    1162           0 : void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
    1163             : {
    1164           0 :     if (!::dbtools::implUpdateObject(this, columnIndex, x))
    1165           0 :         throw SQLException();
    1166           0 : }
    1167             : // -------------------------------------------------------------------------
    1168             : // XRowLocate
    1169           0 : Any SAL_CALL OResultSet::getBookmark(  ) throw( SQLException,  RuntimeException)
    1170             : {
    1171           0 :     fillColumn(0);
    1172           0 :     if(m_aRow[0].isNull())
    1173           0 :         throw SQLException();
    1174           0 :     return m_aRow[0].makeAny();
    1175             : }
    1176           0 : Sequence<sal_Int8> OResultSet::impl_getBookmark(  ) throw( SQLException,  RuntimeException)
    1177             : {
    1178             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
    1179           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1180             : 
    1181             :     TBookmarkPosMap::iterator aFind = ::std::find_if(m_aPosToBookmarks.begin(),m_aPosToBookmarks.end(),
    1182           0 :         ::o3tl::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),m_nRowPos),::o3tl::select2nd<TBookmarkPosMap::value_type>()));
    1183             : 
    1184           0 :     if ( aFind == m_aPosToBookmarks.end() )
    1185             :     {
    1186           0 :         if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
    1187             :         {
    1188           0 :             m_nUseBookmarks = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, SQL_UB_OFF);
    1189             :         }
    1190           0 :         if(m_nUseBookmarks == SQL_UB_OFF)
    1191           0 :             throw SQLException();
    1192             : 
    1193           0 :         fillColumn(0);
    1194           0 :         Sequence<sal_Int8> bookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
    1195           0 :         m_aPosToBookmarks[bookmark] = m_nRowPos;
    1196             :         OSL_ENSURE(bookmark.getLength(),"Invalid bookmark from length 0!");
    1197           0 :         return bookmark;
    1198             :     }
    1199             :     else
    1200             :     {
    1201           0 :         return aFind->first;
    1202             :     }
    1203             : }
    1204             : // -------------------------------------------------------------------------
    1205           0 : sal_Bool SAL_CALL OResultSet::moveToBookmark( const  Any& bookmark ) throw( SQLException,  RuntimeException)
    1206             : {
    1207             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
    1208           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1209           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1210             : 
    1211           0 :     invalidateCache();
    1212           0 :     Sequence<sal_Int8> aBookmark;
    1213           0 :     bookmark >>= aBookmark;
    1214             :     OSL_ENSURE(aBookmark.getLength(),"Invalid bookmark from length 0!");
    1215           0 :     if(aBookmark.getLength())
    1216             :     {
    1217           0 :         SQLRETURN nReturn = setStmtOption<SQLLEN*, SQL_IS_POINTER>(SQL_ATTR_FETCH_BOOKMARK_PTR, reinterpret_cast<SQLLEN*>(aBookmark.getArray()));
    1218             : 
    1219           0 :         if ( SQL_INVALID_HANDLE != nReturn && SQL_ERROR != nReturn )
    1220             :         {
    1221           0 :             m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
    1222           0 :             OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1223           0 :             TBookmarkPosMap::iterator aFind = m_aPosToBookmarks.find(aBookmark);
    1224           0 :             if(aFind != m_aPosToBookmarks.end())
    1225           0 :                 m_nRowPos = aFind->second;
    1226             :             else
    1227           0 :                 m_nRowPos = -1;
    1228           0 :             return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
    1229             :         }
    1230             :     }
    1231           0 :     return sal_False;
    1232             : }
    1233             : // -------------------------------------------------------------------------
    1234           0 : sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const  Any& bookmark, sal_Int32 rows ) throw( SQLException,  RuntimeException)
    1235             : {
    1236             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
    1237           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1238           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1239             : 
    1240             : 
    1241           0 :     invalidateCache();
    1242           0 :     Sequence<sal_Int8> aBookmark;
    1243           0 :     bookmark >>= aBookmark;
    1244           0 :     SQLRETURN nReturn = setStmtOption<SQLLEN*, SQL_IS_POINTER>(SQL_ATTR_FETCH_BOOKMARK_PTR, reinterpret_cast<SQLLEN*>(aBookmark.getArray()));
    1245             :     OSL_UNUSED( nReturn );
    1246             : 
    1247           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows);
    1248           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1249           0 :     return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
    1250             : }
    1251             : // -------------------------------------------------------------------------
    1252           0 : sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& lhs, const  Any& rhs ) throw( SQLException,  RuntimeException)
    1253             : {
    1254             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
    1255           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1256           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1257             : 
    1258           0 :     return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
    1259             : }
    1260             : // -------------------------------------------------------------------------
    1261           0 : sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks(  ) throw( SQLException,  RuntimeException)
    1262             : {
    1263           0 :     return sal_False;
    1264             : }
    1265             : // -------------------------------------------------------------------------
    1266           0 : sal_Int32 SAL_CALL OResultSet::hashBookmark( const  Any& /*bookmark*/ ) throw( SQLException,  RuntimeException)
    1267             : {
    1268           0 :     ::dbtools::throwFunctionNotSupportedException( "XRowLocate::hashBookmark", *this );
    1269           0 :     return 0;
    1270             : }
    1271             : // -------------------------------------------------------------------------
    1272             : // XDeleteRows
    1273           0 : Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const  Sequence<  Any >& rows ) throw( SQLException,  RuntimeException)
    1274             : {
    1275           0 :     Sequence< sal_Int32 > aRet(rows.getLength());
    1276           0 :     sal_Int32 *pRet = aRet.getArray();
    1277             : 
    1278           0 :     const Any *pBegin   = rows.getConstArray();
    1279           0 :     const Any *pEnd     = pBegin + rows.getLength();
    1280             : 
    1281           0 :     for(;pBegin != pEnd;++pBegin,++pRet)
    1282             :     {
    1283             :         try
    1284             :         {
    1285           0 :             if(moveToBookmark(*pBegin))
    1286             :             {
    1287           0 :                 deleteRow();
    1288           0 :                 *pRet = 1;
    1289             :             }
    1290             :         }
    1291           0 :         catch(const SQLException&)
    1292             :         {
    1293           0 :             *pRet = 0;
    1294             :         }
    1295             :     }
    1296           0 :     return aRet;
    1297             : }
    1298             : //------------------------------------------------------------------------------
    1299           0 : template < typename T, SQLINTEGER BufferLength > T OResultSet::getStmtOption (SQLINTEGER fOption, T dflt) const
    1300             : {
    1301           0 :     T result (dflt);
    1302             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
    1303           0 :     N3SQLGetStmtAttr(m_aStatementHandle, fOption, &result, BufferLength, NULL);
    1304           0 :     return result;
    1305             : }
    1306           0 : template < typename T, SQLINTEGER BufferLength > SQLRETURN OResultSet::setStmtOption (SQLINTEGER fOption, T value) const
    1307             : {
    1308             :     OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
    1309           0 :     SQLPOINTER sv = reinterpret_cast<SQLPOINTER>(value);
    1310           0 :     return N3SQLSetStmtAttr(m_aStatementHandle, fOption, sv, BufferLength);
    1311             : }
    1312             : //------------------------------------------------------------------------------
    1313           0 : sal_Int32 OResultSet::getResultSetConcurrency() const
    1314             : {
    1315           0 :     sal_uInt32 nValue = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CONCURRENCY);
    1316           0 :     if(SQL_CONCUR_READ_ONLY == nValue)
    1317           0 :         nValue = ResultSetConcurrency::READ_ONLY;
    1318             :     else
    1319           0 :         nValue = ResultSetConcurrency::UPDATABLE;
    1320             : 
    1321           0 :     return nValue;
    1322             : }
    1323             : //------------------------------------------------------------------------------
    1324           0 : sal_Int32 OResultSet::getResultSetType() const
    1325             : {
    1326           0 :     sal_uInt32 nValue = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_SENSITIVITY);
    1327           0 :     if(SQL_SENSITIVE == nValue)
    1328           0 :         nValue = ResultSetType::SCROLL_SENSITIVE;
    1329           0 :     else if(SQL_INSENSITIVE == nValue)
    1330           0 :         nValue = ResultSetType::SCROLL_INSENSITIVE;
    1331             :     else
    1332             :     {
    1333           0 :         SQLULEN nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE);
    1334           0 :         if(SQL_CURSOR_KEYSET_DRIVEN == nCurType)
    1335           0 :             nValue = ResultSetType::SCROLL_SENSITIVE;
    1336           0 :         else if(SQL_CURSOR_STATIC  == nCurType)
    1337           0 :             nValue = ResultSetType::SCROLL_INSENSITIVE;
    1338           0 :         else if(SQL_CURSOR_FORWARD_ONLY == nCurType)
    1339           0 :             nValue = ResultSetType::FORWARD_ONLY;
    1340           0 :         else if(SQL_CURSOR_DYNAMIC == nCurType)
    1341           0 :             nValue = ResultSetType::SCROLL_SENSITIVE;
    1342             :     }
    1343           0 :     return nValue;
    1344             : }
    1345             : //------------------------------------------------------------------------------
    1346           0 : sal_Int32 OResultSet::getFetchDirection() const
    1347             : {
    1348           0 :     return FetchDirection::FORWARD;
    1349             : }
    1350             : //------------------------------------------------------------------------------
    1351           0 : sal_Int32 OResultSet::getFetchSize() const
    1352             : {
    1353           0 :     return getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE);
    1354             : }
    1355             : //------------------------------------------------------------------------------
    1356           0 : ::rtl::OUString OResultSet::getCursorName() const
    1357             : {
    1358             :     SQLCHAR pName[258];
    1359           0 :     SQLSMALLINT nRealLen = 0;
    1360           0 :     N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen);
    1361           0 :     return ::rtl::OUString::createFromAscii((const char*)pName);
    1362             : }
    1363             : // -------------------------------------------------------------------------
    1364           0 : sal_Bool  OResultSet::isBookmarkable() const
    1365             : {
    1366           0 :     if(!m_aConnectionHandle)
    1367           0 :         return sal_False;
    1368             : 
    1369           0 :     const SQLULEN nCursorType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE);
    1370             : 
    1371           0 :     sal_Int32 nAttr = 0;
    1372             :     try
    1373             :     {
    1374           0 :         switch(nCursorType)
    1375             :         {
    1376             :         case SQL_CURSOR_FORWARD_ONLY:
    1377           0 :             return sal_False;
    1378             :         case SQL_CURSOR_STATIC:
    1379           0 :             OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_STATIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
    1380           0 :             break;
    1381             :         case SQL_CURSOR_KEYSET_DRIVEN:
    1382           0 :             OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_KEYSET_CURSOR_ATTRIBUTES1,nAttr,NULL);
    1383           0 :             break;
    1384             :         case SQL_CURSOR_DYNAMIC:
    1385           0 :             OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
    1386           0 :             break;
    1387             :         }
    1388             :     }
    1389           0 :     catch(const Exception&)
    1390             :     {
    1391           0 :         return sal_False;
    1392             :     }
    1393             : 
    1394           0 :     if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
    1395             :     {
    1396           0 :         m_nUseBookmarks = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, SQL_UB_OFF);
    1397             :     }
    1398             : 
    1399           0 :     return (m_nUseBookmarks != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK;
    1400             : }
    1401             : //------------------------------------------------------------------------------
    1402           0 : void OResultSet::setFetchDirection(sal_Int32 _par0)
    1403             : {
    1404           0 :     ::dbtools::throwFunctionNotSupportedException( "setFetchDirection", *this );
    1405             : 
    1406             :     OSL_ENSURE(_par0>0,"Illegal fetch direction!");
    1407           0 :     if ( _par0 > 0 )
    1408             :     {
    1409           0 :         setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE, _par0);
    1410             :     }
    1411           0 : }
    1412             : //------------------------------------------------------------------------------
    1413           0 : void OResultSet::setFetchSize(sal_Int32 _par0)
    1414             : {
    1415             :     OSL_ENSURE(_par0>0,"Illegal fetch size!");
    1416           0 :     if ( _par0 != 1 )
    1417             :     {
    1418           0 :         throw ::com::sun::star::beans::PropertyVetoException("SDBC/ODBC layer not prepared for fetchSize > 1", *this);
    1419             :     }
    1420           0 :     if ( _par0 > 0 )
    1421             :     {
    1422           0 :         setStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_ARRAY_SIZE, _par0);
    1423           0 :         delete [] m_pRowStatusArray;
    1424             : 
    1425           0 :         m_pRowStatusArray = new SQLUSMALLINT[_par0];
    1426           0 :         setStmtOption<SQLUSMALLINT*, SQL_IS_POINTER>(SQL_ATTR_ROW_STATUS_PTR, m_pRowStatusArray);
    1427             :     }
    1428           0 : }
    1429             : // -------------------------------------------------------------------------
    1430           0 : IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
    1431             : {
    1432           0 :     Sequence< Property > aProps(6);
    1433           0 :     Property* pProperties = aProps.getArray();
    1434           0 :     sal_Int32 nPos = 0;
    1435           0 :     DECL_PROP1IMPL(CURSORNAME,          ::rtl::OUString) PropertyAttribute::READONLY);
    1436           0 :     DECL_PROP0(FETCHDIRECTION,          sal_Int32);
    1437           0 :     DECL_PROP0(FETCHSIZE,               sal_Int32);
    1438           0 :     DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
    1439           0 :     DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
    1440           0 :     DECL_PROP1IMPL(RESULTSETTYPE,       sal_Int32) PropertyAttribute::READONLY);
    1441             : 
    1442           0 :     return new OPropertyArrayHelper(aProps);
    1443             : }
    1444             : // -------------------------------------------------------------------------
    1445           0 : IPropertyArrayHelper & OResultSet::getInfoHelper()
    1446             : {
    1447           0 :     return *const_cast<OResultSet*>(this)->getArrayHelper();
    1448             : }
    1449             : // -------------------------------------------------------------------------
    1450           0 : sal_Bool OResultSet::convertFastPropertyValue(
    1451             :                             Any & rConvertedValue,
    1452             :                             Any & rOldValue,
    1453             :                             sal_Int32 nHandle,
    1454             :                             const Any& rValue )
    1455             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
    1456             : {
    1457           0 :     switch(nHandle)
    1458             :     {
    1459             :         case PROPERTY_ID_ISBOOKMARKABLE:
    1460             :         case PROPERTY_ID_CURSORNAME:
    1461             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
    1462             :         case PROPERTY_ID_RESULTSETTYPE:
    1463           0 :             throw ::com::sun::star::lang::IllegalArgumentException();
    1464             :         case PROPERTY_ID_FETCHDIRECTION:
    1465           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
    1466             :         case PROPERTY_ID_FETCHSIZE:
    1467           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
    1468             :         default:
    1469             :             ;
    1470             :     }
    1471           0 :     return sal_False;
    1472             : }
    1473             : // -------------------------------------------------------------------------
    1474           0 : void OResultSet::setFastPropertyValue_NoBroadcast(
    1475             :                                 sal_Int32 nHandle,
    1476             :                                 const Any& rValue
    1477             :                                                  )
    1478             :                                                  throw (Exception)
    1479             : {
    1480           0 :     switch(nHandle)
    1481             :     {
    1482             :         case PROPERTY_ID_ISBOOKMARKABLE:
    1483             :         case PROPERTY_ID_CURSORNAME:
    1484             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
    1485             :         case PROPERTY_ID_RESULTSETTYPE:
    1486           0 :             throw Exception();
    1487             :         case PROPERTY_ID_FETCHDIRECTION:
    1488           0 :             setFetchDirection(getINT32(rValue));
    1489           0 :             break;
    1490             :         case PROPERTY_ID_FETCHSIZE:
    1491           0 :             setFetchSize(getINT32(rValue));
    1492           0 :             break;
    1493             :         default:
    1494             :             ;
    1495             :     }
    1496           0 : }
    1497             : // -------------------------------------------------------------------------
    1498           0 : void OResultSet::getFastPropertyValue(
    1499             :                                 Any& rValue,
    1500             :                                 sal_Int32 nHandle
    1501             :                                      ) const
    1502             : {
    1503           0 :     switch(nHandle)
    1504             :     {
    1505             :         case PROPERTY_ID_ISBOOKMARKABLE:
    1506           0 :             rValue = bool2any(isBookmarkable());
    1507           0 :             break;
    1508             :         case PROPERTY_ID_CURSORNAME:
    1509           0 :             rValue <<= getCursorName();
    1510           0 :             break;
    1511             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
    1512           0 :             rValue <<= getResultSetConcurrency();
    1513           0 :             break;
    1514             :         case PROPERTY_ID_RESULTSETTYPE:
    1515           0 :             rValue <<= getResultSetType();
    1516           0 :             break;
    1517             :         case PROPERTY_ID_FETCHDIRECTION:
    1518           0 :             rValue <<= getFetchDirection();
    1519           0 :             break;
    1520             :         case PROPERTY_ID_FETCHSIZE:
    1521           0 :             rValue <<= getFetchSize();
    1522           0 :             break;
    1523             :     }
    1524           0 : }
    1525             : // -------------------------------------------------------------------------
    1526           0 : void OResultSet::fillColumn(const sal_Int32 _nColumn)
    1527             : {
    1528             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillColumn" );
    1529             : 
    1530           0 :     ensureCacheForColumn(_nColumn);
    1531             : 
    1532           0 :     if (m_aRow[_nColumn].isBound())
    1533           0 :         return;
    1534             : 
    1535             :     sal_Int32 curCol;
    1536           0 :     if(m_bFetchDataInOrder)
    1537             :     {
    1538             :         // m_aRow necessarily has a prefix of bound values, then all unbound values
    1539             :         // EXCEPT for column 0
    1540             :         // so use binary search to find the earliest unbound value before or at _nColumn
    1541           0 :         sal_Int32 lower=0;
    1542           0 :         sal_Int32 upper=_nColumn;
    1543             : 
    1544           0 :         while (lower < upper)
    1545             :         {
    1546           0 :             const sal_Int32 middle=(upper-lower)/2 + lower;
    1547           0 :             if(m_aRow[middle].isBound())
    1548             :             {
    1549           0 :                 lower=middle+1;
    1550             :             }
    1551             :             else
    1552             :             {
    1553           0 :                 upper=middle;
    1554             :             }
    1555             :         }
    1556             : 
    1557           0 :         curCol = upper;
    1558             :     }
    1559             :     else
    1560             :     {
    1561           0 :         curCol = _nColumn;
    1562             :     }
    1563             : 
    1564           0 :     TDataRow::iterator pColumn      = m_aRow.begin() + curCol;
    1565           0 :     TDataRow::iterator pColumnEnd   = m_aRow.begin() + _nColumn + 1;
    1566             : 
    1567           0 :     if(curCol==0)
    1568             :     {
    1569             :         try
    1570             :         {
    1571           0 :             *pColumn=impl_getBookmark();
    1572             :         }
    1573           0 :         catch (SQLException &)
    1574             :         {
    1575           0 :             pColumn->setNull();
    1576             :         }
    1577           0 :         pColumn->setBound(true);
    1578           0 :         ++curCol;
    1579           0 :         ++pColumn;
    1580             :     }
    1581             : 
    1582           0 :     for (; pColumn != pColumnEnd; ++curCol, ++pColumn)
    1583             :     {
    1584           0 :         const sal_Int32 nType = pColumn->getTypeKind();
    1585           0 :         switch (nType)
    1586             :         {
    1587             :         case DataType::CHAR:
    1588             :         case DataType::VARCHAR:
    1589             :         case DataType::DECIMAL:
    1590             :         case DataType::NUMERIC:
    1591             :         case DataType::LONGVARCHAR:
    1592             :         case DataType::CLOB:
    1593           0 :             *pColumn=impl_getString(curCol);
    1594           0 :             break;
    1595             :         case DataType::FLOAT:
    1596           0 :             *pColumn = impl_getValue<float>(curCol, SQL_C_FLOAT);
    1597           0 :             break;
    1598             :         case DataType::REAL:
    1599             :         case DataType::DOUBLE:
    1600           0 :             *pColumn = impl_getValue<double>(curCol, SQL_C_DOUBLE);
    1601           0 :             break;
    1602             :         case DataType::BINARY:
    1603             :         case DataType::VARBINARY:
    1604             :         case DataType::LONGVARBINARY:
    1605             :         case DataType::BLOB:
    1606           0 :             *pColumn = impl_getBytes(curCol);
    1607           0 :             break;
    1608             :         case DataType::DATE:
    1609           0 :             *pColumn = impl_getDate(curCol);
    1610           0 :             break;
    1611             :         case DataType::TIME:
    1612           0 :             *pColumn = impl_getTime(curCol);
    1613           0 :             break;
    1614             :         case DataType::TIMESTAMP:
    1615           0 :             *pColumn = impl_getTimestamp(curCol);
    1616           0 :             break;
    1617             :         case DataType::BIT:
    1618           0 :             *pColumn = impl_getBoolean(curCol);
    1619           0 :             break;
    1620             :         case DataType::TINYINT:
    1621           0 :             *pColumn = impl_getValue<sal_Int8>(curCol, SQL_C_TINYINT);
    1622           0 :             break;
    1623             :         case DataType::SMALLINT:
    1624           0 :             *pColumn = impl_getValue<sal_Int16>(curCol, SQL_C_SHORT);
    1625           0 :             break;
    1626             :         case DataType::INTEGER:
    1627           0 :             *pColumn = impl_getValue<sal_Int32>(curCol, SQL_C_LONG);
    1628           0 :             break;
    1629             :         case DataType::BIGINT:
    1630           0 :             *pColumn = impl_getLong(curCol);
    1631           0 :             break;
    1632             :         default:
    1633             :             OSL_FAIL("Unknown DataType");
    1634             :         }
    1635             : 
    1636           0 :         if ( m_bWasNull )
    1637           0 :             pColumn->setNull();
    1638           0 :         pColumn->setBound(true);
    1639           0 :         if(nType != pColumn->getTypeKind())
    1640             :         {
    1641           0 :             pColumn->setTypeKind(nType);
    1642             :         }
    1643             :     }
    1644             : }
    1645             : // -----------------------------------------------------------------------------
    1646           0 : void SAL_CALL OResultSet::acquire() throw()
    1647             : {
    1648           0 :     OResultSet_BASE::acquire();
    1649           0 : }
    1650             : // -----------------------------------------------------------------------------
    1651           0 : void SAL_CALL OResultSet::release() throw()
    1652             : {
    1653           0 :     OResultSet_BASE::release();
    1654           0 : }
    1655             : // -----------------------------------------------------------------------------
    1656           0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
    1657             : {
    1658           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
    1659             : }
    1660             : // -----------------------------------------------------------------------------
    1661           0 : sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool /*_bRetrieveData*/)
    1662             : {
    1663             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::move" );
    1664           0 :     SQLSMALLINT nFetchOrientation = SQL_FETCH_NEXT;
    1665           0 :     switch(_eCursorPosition)
    1666             :     {
    1667             :         case IResultSetHelper::NEXT:
    1668           0 :             nFetchOrientation = SQL_FETCH_NEXT;
    1669           0 :             break;
    1670             :         case IResultSetHelper::PRIOR:
    1671           0 :             nFetchOrientation = SQL_FETCH_PRIOR;
    1672           0 :             break;
    1673             :         case IResultSetHelper::FIRST:
    1674           0 :             nFetchOrientation = SQL_FETCH_FIRST;
    1675           0 :             break;
    1676             :         case IResultSetHelper::LAST:
    1677           0 :             nFetchOrientation = SQL_FETCH_LAST;
    1678           0 :             break;
    1679             :         case IResultSetHelper::RELATIVE:
    1680           0 :             nFetchOrientation = SQL_FETCH_RELATIVE;
    1681           0 :             break;
    1682             :         case IResultSetHelper::ABSOLUTE:
    1683           0 :             nFetchOrientation = SQL_FETCH_ABSOLUTE;
    1684           0 :             break;
    1685             :         case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
    1686             :         {
    1687           0 :             TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
    1688           0 :             TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
    1689           0 :             for (; aIter != aEnd; ++aIter)
    1690             :             {
    1691           0 :                 if ( aIter->second == _nOffset )
    1692           0 :                     return moveToBookmark(makeAny(aIter->first));
    1693             :             }
    1694             :             OSL_FAIL("Bookmark not found!");
    1695             :         }
    1696           0 :         return sal_False;
    1697             :     }
    1698             : 
    1699           0 :     m_bEOF = sal_False;
    1700           0 :     invalidateCache();
    1701             : 
    1702           0 :     SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
    1703             :     // TODO FIXME: both of these will misbehave for
    1704             :     // _eCursorPosition == IResultSetHelper::NEXT/PREVIOUS
    1705             :     // when fetchSize > 1
    1706           0 :     if ( !m_bUseFetchScroll && _eCursorPosition == IResultSetHelper::NEXT )
    1707           0 :         m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
    1708             :     else
    1709           0 :         m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,nFetchOrientation,_nOffset);
    1710             : 
    1711             :     OSL_TRACE( __FILE__": OResultSet::move(%d,%d), FetchState = %d",nFetchOrientation,_nOffset,m_nCurrentFetchState);
    1712           0 :     OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1713             : 
    1714           0 :     const bool bSuccess = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
    1715           0 :     if ( bSuccess )
    1716             :     {
    1717           0 :         switch(_eCursorPosition)
    1718             :         {
    1719             :             case IResultSetHelper::NEXT:
    1720           0 :                 ++m_nRowPos;
    1721           0 :                 break;
    1722             :             case IResultSetHelper::PRIOR:
    1723           0 :                 --m_nRowPos;
    1724           0 :                 break;
    1725             :             case IResultSetHelper::FIRST:
    1726           0 :                 m_nRowPos = 1;
    1727           0 :                 break;
    1728             :             case IResultSetHelper::LAST:
    1729           0 :                 m_bEOF = sal_True;
    1730           0 :                 break;
    1731             :             case IResultSetHelper::RELATIVE:
    1732           0 :                 m_nRowPos += _nOffset;
    1733           0 :                 break;
    1734             :             case IResultSetHelper::ABSOLUTE:
    1735             :             case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
    1736           0 :                 m_nRowPos = _nOffset;
    1737           0 :                 break;
    1738             :         } // switch(_eCursorPosition)
    1739           0 :         if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
    1740             :         {
    1741           0 :             m_nUseBookmarks = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_USE_BOOKMARKS, SQL_UB_OFF);
    1742             :         }
    1743           0 :         if ( m_nUseBookmarks == SQL_UB_OFF )
    1744             :         {
    1745           0 :             m_aRow[0].setNull();
    1746             :         }
    1747             :         else
    1748             :         {
    1749           0 :             ensureCacheForColumn(0);
    1750           0 :             Sequence<sal_Int8> bookmark  = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
    1751           0 :             m_aPosToBookmarks[bookmark] = m_nRowPos;
    1752             :             OSL_ENSURE(bookmark.getLength(),"Invalid bookmark from length 0!");
    1753           0 :             m_aRow[0] = bookmark;
    1754             :         }
    1755           0 :         m_aRow[0].setBound(true);
    1756             :     }
    1757           0 :     else if ( IResultSetHelper::PRIOR == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA )
    1758             :         // we went beforeFirst
    1759           0 :         m_nRowPos = 0;
    1760           0 :     else if(IResultSetHelper::NEXT == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA)
    1761             :         // we went afterLast
    1762           0 :         ++m_nRowPos;
    1763             : 
    1764           0 :     return bSuccess;
    1765             : }
    1766             : // -----------------------------------------------------------------------------
    1767           0 : sal_Int32 OResultSet::getDriverPos() const
    1768             : {
    1769           0 :     sal_Int32 nValue = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_ROW_NUMBER);
    1770             :     OSL_TRACE( __FILE__": OResultSet::getDriverPos() = RowNum = %d, RowPos = %d", nValue, m_nRowPos);
    1771           0 :     return nValue ? nValue : m_nRowPos;
    1772             : }
    1773             : // -----------------------------------------------------------------------------
    1774           0 : sal_Bool OResultSet::deletedVisible() const
    1775             : {
    1776           0 :     return sal_False;
    1777             : }
    1778             : // -----------------------------------------------------------------------------
    1779           0 : sal_Bool OResultSet::isRowDeleted() const
    1780             : {
    1781           0 :     return m_pRowStatusArray[0] == SQL_ROW_DELETED;
    1782             : }
    1783             : // -----------------------------------------------------------------------------
    1784           0 : sal_Bool OResultSet::moveImpl(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
    1785             : {
    1786           0 :     ::osl::MutexGuard aGuard( m_aMutex );
    1787           0 :     checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
    1788             :     return (m_pSkipDeletedSet != NULL)
    1789           0 :                 ?   m_pSkipDeletedSet->skipDeleted(_eCursorPosition,_nOffset,_bRetrieveData)
    1790           0 :                 :   move(_eCursorPosition,_nOffset,_bRetrieveData);
    1791             : }
    1792             : // -----------------------------------------------------------------------------
    1793           0 : void OResultSet::fillNeededData(SQLRETURN _nRet)
    1794             : {
    1795             :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillNeededData" );
    1796           0 :     SQLRETURN nRet = _nRet;
    1797           0 :     if( nRet == SQL_NEED_DATA)
    1798             :     {
    1799           0 :         void* pColumnIndex = 0;
    1800           0 :         nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
    1801             : 
    1802           0 :         do
    1803             :         {
    1804           0 :             if (nRet != SQL_SUCCESS && nRet != SQL_SUCCESS_WITH_INFO && nRet != SQL_NEED_DATA)
    1805             :                 break;
    1806             : 
    1807           0 :             sal_IntPtr nColumnIndex ( reinterpret_cast<sal_IntPtr>(pColumnIndex));
    1808           0 :             Sequence< sal_Int8 > aSeq;
    1809           0 :             switch(m_aRow[nColumnIndex].getTypeKind())
    1810             :             {
    1811             :                 case DataType::BINARY:
    1812             :                 case DataType::VARBINARY:
    1813             :                 case DataType::LONGVARBINARY:
    1814             :                 case DataType::BLOB:
    1815           0 :                     aSeq = m_aRow[nColumnIndex];
    1816           0 :                     N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength());
    1817           0 :                     break;
    1818             :                 case SQL_WLONGVARCHAR:
    1819             :                 {
    1820           0 :                     ::rtl::OUString sRet;
    1821           0 :                     sRet = m_aRow[nColumnIndex].getString();
    1822           0 :                     nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)sRet.getStr(), sizeof(sal_Unicode)*sRet.getLength());
    1823           0 :                     break;
    1824             :                 }
    1825             :                 case DataType::LONGVARCHAR:
    1826             :                 case DataType::CLOB:
    1827             :                 {
    1828           0 :                     ::rtl::OUString sRet;
    1829           0 :                     sRet = m_aRow[nColumnIndex].getString();
    1830           0 :                     ::rtl::OString aString(::rtl::OUStringToOString(sRet,m_nTextEncoding));
    1831           0 :                     nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)aString.getStr(), aString.getLength());
    1832           0 :                     break;
    1833             :                 }
    1834             :                 default:
    1835             :                     OSL_FAIL("Not supported at the moment!");
    1836             :             }
    1837           0 :             nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
    1838             :         }
    1839             :         while (nRet == SQL_NEED_DATA);
    1840             :     }
    1841           0 : }
    1842             : // -----------------------------------------------------------------------------
    1843           0 : SWORD OResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
    1844             : {
    1845           0 :     ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
    1846           0 :     if ( aFind == m_aODBCColumnTypes.end() )
    1847           0 :         aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
    1848           0 :     return aFind->second;
    1849             : }
    1850             : 
    1851             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10