LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbcbase - OResultSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 846 0.0 %
Date: 2012-08-25 Functions: 0 118 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10