LCOV - code coverage report
Current view: top level - connectivity/source/drivers/odbc - ODatabaseMetaDataResultSet.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 661 0.0 %
Date: 2014-04-14 Functions: 0 88 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "TConnection.hxx"
      21             : 
      22             : #include "odbc/ODatabaseMetaDataResultSet.hxx"
      23             : #include <com/sun/star/sdbc/DataType.hpp>
      24             : #include <com/sun/star/sdbc/KeyRule.hpp>
      25             : #include <com/sun/star/sdbc/ProcedureResult.hpp>
      26             : #include <com/sun/star/sdbc/IndexType.hpp>
      27             : #include <comphelper/property.hxx>
      28             : #include <com/sun/star/lang/DisposedException.hpp>
      29             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      30             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      31             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      32             : #include <cppuhelper/typeprovider.hxx>
      33             : #include <comphelper/sequence.hxx>
      34             : #include "odbc/OResultSetMetaData.hxx"
      35             : #include "odbc/OTools.hxx"
      36             : #include <comphelper/types.hxx>
      37             : #include "FDatabaseMetaDataResultSetMetaData.hxx"
      38             : #include <connectivity/dbexception.hxx>
      39             : 
      40             : using namespace ::comphelper;
      41             : 
      42             : 
      43             : using namespace connectivity::odbc;
      44             : using namespace cppu;
      45             : 
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace com::sun::star::uno;
      48             : using namespace com::sun::star::beans;
      49             : using namespace com::sun::star::sdbc;
      50             : using namespace com::sun::star::util;
      51             : 
      52             : 
      53           0 : ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection)
      54             :     :ODatabaseMetaDataResultSet_BASE(m_aMutex)
      55             :     ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
      56             : 
      57           0 :     ,m_aStatementHandle(_pConnection->createStatementHandle())
      58             :     ,m_aStatement(NULL)
      59             :     ,m_xMetaData(NULL)
      60             :     ,m_pRowStatusArray(NULL)
      61             :     ,m_pConnection(_pConnection)
      62           0 :     ,m_nTextEncoding(_pConnection->getTextEncoding())
      63             :     ,m_nRowPos(-1)
      64             :     ,m_nDriverColumnCount(0)
      65             :     ,m_nCurrentFetchState(0)
      66             :     ,m_bWasNull(sal_True)
      67           0 :     ,m_bEOF(sal_False)
      68             : {
      69             :     OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
      70           0 :     if( SQL_NULL_HANDLE == m_aStatementHandle )
      71           0 :         throw RuntimeException();
      72             : 
      73           0 :     osl_atomic_increment( &m_refCount );
      74           0 :     m_pConnection->acquire();
      75           0 :     m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
      76           0 :     osl_atomic_decrement( &m_refCount );
      77             :     //  allocBuffer();
      78           0 : }
      79             : 
      80             : 
      81           0 : ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
      82             : {
      83             :     OSL_ENSURE(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed,"Object wasn't disposed!");
      84           0 :     if(!ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed)
      85             :     {
      86           0 :         osl_atomic_increment( &m_refCount );
      87           0 :         dispose();
      88             :     }
      89           0 :     delete [] m_pRowStatusArray;
      90           0 : }
      91             : 
      92           0 : void ODatabaseMetaDataResultSet::disposing(void)
      93             : {
      94           0 :     OPropertySetHelper::disposing();
      95             : 
      96           0 :     ::osl::MutexGuard aGuard(m_aMutex);
      97             : 
      98           0 :     m_pConnection->freeStatementHandle(m_aStatementHandle);
      99             : 
     100           0 :     m_aStatement    = NULL;
     101           0 : m_xMetaData.clear();
     102           0 :     m_pConnection->release();
     103           0 : }
     104             : 
     105           0 : Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
     106             : {
     107           0 :     Any aRet = OPropertySetHelper::queryInterface(rType);
     108           0 :     return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
     109             : }
     110             : 
     111           0 : Reference< XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo(  ) throw(RuntimeException, std::exception)
     112             : {
     113           0 :     return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
     114             : }
     115             : 
     116           0 : void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
     117             : {
     118           0 :     ODatabaseMetaDataResultSet_BASE::acquire();
     119           0 : }
     120             : 
     121           0 : void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
     122             : {
     123           0 :     ODatabaseMetaDataResultSet_BASE::release();
     124           0 : }
     125             : 
     126           0 : Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes(  ) throw(RuntimeException, std::exception)
     127             : {
     128           0 :     ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
     129           0 :                                     ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
     130           0 :                                     ::getCppuType( (const Reference< XPropertySet > *)0 ));
     131             : 
     132           0 :     return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
     133             : }
     134             : 
     135           0 : sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32  column)
     136             : {
     137           0 :     sal_Int32   map = column;
     138             : 
     139           0 :     if (!m_aColMapping.empty())
     140             :     {
     141             :         // Validate column number
     142           0 :         map = m_aColMapping[column];
     143             :     }
     144             : 
     145           0 :     return map;
     146             : }
     147             : 
     148             : 
     149           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& columnName ) throw(SQLException, RuntimeException, std::exception)
     150             : {
     151             : 
     152           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     153           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     154             : 
     155             : 
     156           0 :     Reference< XResultSetMetaData > xMeta = getMetaData();
     157           0 :     sal_Int32 nLen = xMeta->getColumnCount();
     158           0 :     sal_Int32 i = 1;
     159           0 :     for(;i<=nLen;++i)
     160             :     {
     161           0 :         if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
     162           0 :                 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
     163           0 :             return i;
     164             :     }
     165             : 
     166           0 :     ::dbtools::throwInvalidColumnException( columnName, *this );
     167             :     assert(false);
     168           0 :     return 0; // Never reached
     169             : }
     170             : 
     171           0 : template < typename T, SQLSMALLINT sqlTypeId > T ODatabaseMetaDataResultSet::getInteger ( sal_Int32 columnIndex )
     172             : {
     173           0 :     ::cppu::OBroadcastHelper& rBHelper(ODatabaseMetaDataResultSet_BASE::rBHelper);
     174           0 :     checkDisposed(rBHelper.bDisposed);
     175           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     176             : 
     177           0 :     columnIndex = mapColumn(columnIndex);
     178           0 :     T nVal = 0;
     179           0 :     if(columnIndex <= m_nDriverColumnCount)
     180             :     {
     181           0 :         getValue<T>(m_pConnection, m_aStatementHandle, columnIndex, sqlTypeId, m_bWasNull, **this, nVal);
     182             : 
     183           0 :         if ( !m_aValueRange.empty() )
     184             :         {
     185           0 :             ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter (m_aValueRange.find(columnIndex));
     186           0 :             if ( aValueRangeIter != m_aValueRange.end() )
     187           0 :                 return static_cast<T>(aValueRangeIter->second[nVal]);
     188             :         }
     189             :     }
     190             :     else
     191           0 :         m_bWasNull = sal_True;
     192           0 :     return nVal;
     193             : }
     194             : 
     195             : 
     196           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     197             : {
     198           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
     199           0 :     return NULL;
     200             : }
     201             : 
     202           0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     203             : {
     204           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getCharacterStream", *this );
     205           0 :     return NULL;
     206             : }
     207             : 
     208             : 
     209           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     210             : {
     211             : 
     212           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     213           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     214             : 
     215           0 :     columnIndex = mapColumn(columnIndex);
     216             : 
     217           0 :     sal_Bool bRet = sal_False;
     218           0 :     if(columnIndex <= m_nDriverColumnCount)
     219             :     {
     220           0 :         sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
     221           0 :         switch(nType)
     222             :         {
     223             :             case DataType::BIT:
     224             :                 {
     225           0 :                     sal_Int8 nValue = 0;
     226           0 :                     OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
     227           0 :                     bRet = nValue != 0;
     228             :                 }
     229           0 :                 break;
     230             :             default:
     231           0 :                 bRet = getInt(columnIndex) != 0;
     232             :         }
     233             :     }
     234           0 :     return bRet;
     235             : }
     236             : 
     237             : 
     238           0 : sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     239             : {
     240           0 :     return getInteger<sal_Int8, SQL_C_STINYINT>( columnIndex );
     241             : }
     242             : 
     243             : 
     244           0 : Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     245             : {
     246             : 
     247           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     248           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     249             : 
     250             : 
     251           0 :     columnIndex = mapColumn(columnIndex);
     252           0 :     if(columnIndex <= m_nDriverColumnCount)
     253             :     {
     254           0 :         sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
     255           0 :         switch(nType)
     256             :         {
     257             :             case DataType::CHAR:
     258             :             case DataType::VARCHAR:
     259             :             case DataType::LONGVARCHAR:
     260             :             {
     261           0 :                 OUString aRet = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
     262           0 :                 return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
     263             :             }
     264             :         }
     265           0 :         return OTools::getBytesValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
     266             :     }
     267             :     else
     268           0 :         m_bWasNull = sal_True;
     269           0 :     return Sequence<sal_Int8>();
     270             : }
     271             : 
     272             : 
     273           0 : ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     274             : {
     275           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     276           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     277             : 
     278             : 
     279           0 :     columnIndex = mapColumn(columnIndex);
     280           0 :     if(columnIndex <= m_nDriverColumnCount)
     281             :     {
     282             :         DATE_STRUCT aDate;
     283           0 :         aDate.day = 0;
     284           0 :         aDate.month = 0;
     285           0 :         aDate.year = 0;
     286           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
     287           0 :         return Date(aDate.day,aDate.month,aDate.year);
     288             :     }
     289             :     else
     290           0 :         m_bWasNull = sal_True;
     291           0 :     return Date();
     292             : }
     293             : 
     294             : 
     295           0 : double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     296             : {
     297             : 
     298           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     299           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     300             : 
     301             : 
     302           0 :     columnIndex = mapColumn(columnIndex);
     303           0 :     double nValue(0.0);
     304           0 :     if(columnIndex <= m_nDriverColumnCount)
     305           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
     306             :     else
     307           0 :         m_bWasNull = sal_True;
     308           0 :     return nValue;
     309             : }
     310             : 
     311             : 
     312           0 : float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     313             : {
     314             : 
     315           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     316           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     317             : 
     318             : 
     319           0 :     columnIndex = mapColumn(columnIndex);
     320           0 :     float nVal(0);
     321           0 :     if(columnIndex <= m_nDriverColumnCount)
     322           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
     323             :     else
     324           0 :         m_bWasNull = sal_True;
     325           0 :     return nVal;
     326             : }
     327             : 
     328             : 
     329           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     330             : {
     331           0 :     return getInteger<sal_Int32, SQL_C_SLONG>( columnIndex );
     332             : }
     333             : 
     334             : 
     335           0 : sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow(  ) throw(SQLException, RuntimeException, std::exception)
     336             : {
     337           0 :     return 0;
     338             : }
     339             : 
     340             : 
     341           0 : sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     342             : {
     343           0 :     return getInteger<sal_Int64, SQL_C_SBIGINT>( columnIndex );
     344             : }
     345             : 
     346             : 
     347           0 : Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData(  ) throw(SQLException, RuntimeException, std::exception)
     348             : {
     349           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     350           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     351           0 :     return m_xMetaData.is() ? m_xMetaData :  (m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle));
     352             : }
     353             : 
     354           0 : Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     355             : {
     356           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
     357           0 :     return NULL;
     358             : }
     359             : 
     360           0 : Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     361             : {
     362           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
     363           0 :     return NULL;
     364             : }
     365             : 
     366           0 : Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     367             : {
     368           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
     369           0 :     return NULL;
     370             : }
     371             : 
     372             : 
     373           0 : Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException, std::exception)
     374             : {
     375           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
     376           0 :     return NULL;
     377             : }
     378             : 
     379             : 
     380           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException, std::exception)
     381             : {
     382           0 :     ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this );
     383           0 :     return Any();
     384             : }
     385             : 
     386             : 
     387           0 : sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     388             : {
     389           0 :     return getInteger<sal_Int16, SQL_C_SSHORT>( columnIndex );
     390             : }
     391             : 
     392             : 
     393           0 : OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     394             : {
     395             : 
     396           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     397           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     398             : 
     399             : 
     400           0 :     columnIndex = mapColumn(columnIndex);
     401           0 :     OUString aVal;
     402           0 :     if(columnIndex <= m_nDriverColumnCount)
     403           0 :         aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
     404             :     else
     405           0 :         m_bWasNull = sal_True;
     406             : 
     407           0 :     return aVal;
     408             : }
     409             : 
     410             : 
     411             : 
     412             : 
     413           0 : ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     414             : {
     415             : 
     416           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     417           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     418             : 
     419             : 
     420           0 :     columnIndex = mapColumn(columnIndex);
     421           0 :     TIME_STRUCT aTime={0,0,0};
     422           0 :     if(columnIndex <= m_nDriverColumnCount)
     423           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
     424             :     else
     425           0 :         m_bWasNull = sal_True;
     426           0 :     return Time(0, aTime.second,aTime.minute,aTime.hour, false);
     427             : }
     428             : 
     429             : 
     430             : 
     431           0 : ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
     432             : {
     433             : 
     434           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     435           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     436             : 
     437             : 
     438           0 :     columnIndex = mapColumn(columnIndex);
     439           0 :     TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
     440           0 :     if(columnIndex <= m_nDriverColumnCount)
     441           0 :         OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime);
     442             :     else
     443           0 :         m_bWasNull = sal_True;
     444             :     return DateTime(aTime.fraction, aTime.second, aTime.minute, aTime.hour,
     445           0 :             aTime.day, aTime.month, aTime.year, false);
     446             : }
     447             : 
     448             : 
     449           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast(  ) throw(SQLException, RuntimeException, std::exception)
     450             : {
     451             : 
     452           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     453           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     454             : 
     455             : 
     456           0 :     return m_nCurrentFetchState == SQL_NO_DATA;
     457             : }
     458             : 
     459           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst(  ) throw(SQLException, RuntimeException, std::exception)
     460             : {
     461             : 
     462           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     463           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     464             : 
     465             : 
     466           0 :     return m_nRowPos == 1;
     467             : }
     468             : 
     469           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast(  ) throw(SQLException, RuntimeException, std::exception)
     470             : {
     471             : 
     472           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     473           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     474             : 
     475             : 
     476           0 :     return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
     477             : }
     478             : 
     479           0 : void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     480             : {
     481             : 
     482           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     483           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     484             : 
     485             : 
     486           0 :     if(first())
     487           0 :         previous();
     488           0 :     m_nCurrentFetchState = SQL_SUCCESS;
     489           0 : }
     490             : 
     491           0 : void SAL_CALL ODatabaseMetaDataResultSet::afterLast(  ) throw(SQLException, RuntimeException, std::exception)
     492             : {
     493             : 
     494           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     495           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     496             : 
     497             : 
     498           0 :     if(last())
     499           0 :         next();
     500           0 : }
     501             : 
     502             : 
     503           0 : void SAL_CALL ODatabaseMetaDataResultSet::close(  ) throw(SQLException, RuntimeException, std::exception)
     504             : {
     505             :     {
     506             : 
     507           0 :         checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     508           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     509             : 
     510             :     }
     511           0 :     dispose();
     512           0 : }
     513             : 
     514             : 
     515           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first(  ) throw(SQLException, RuntimeException, std::exception)
     516             : {
     517             : 
     518           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     519           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     520             : 
     521           0 :     m_bEOF = sal_False;
     522             : 
     523           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
     524           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     525           0 :     sal_Bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
     526           0 :     if( bRet )
     527           0 :         m_nRowPos = 1;
     528           0 :     return bRet;
     529             : }
     530             : 
     531             : 
     532           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last(  ) throw(SQLException, RuntimeException, std::exception)
     533             : {
     534           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
     535           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     536             : 
     537             : 
     538           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
     539           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     540             :     // here I know definitely that I stand on the last record
     541           0 :     sal_Bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
     542           0 :     if( bRet )
     543           0 :         m_bEOF = sal_True;
     544           0 :     return bRet;
     545             : }
     546             : 
     547           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     548             : {
     549             : 
     550           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     551           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     552             : 
     553           0 :     m_bEOF = sal_False;
     554             : 
     555           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
     556           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     557           0 :     sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     558           0 :     if(bRet)
     559           0 :         m_nRowPos = row;
     560           0 :     return bRet;
     561             : }
     562             : 
     563           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
     564             : {
     565             : 
     566           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     567           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     568             : 
     569           0 :     m_bEOF = sal_False;
     570             : 
     571           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
     572           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     573           0 :     sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     574           0 :     if(bRet)
     575           0 :         m_nRowPos += row;
     576           0 :     return bRet;
     577             : }
     578             : 
     579           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous(  ) throw(SQLException, RuntimeException, std::exception)
     580             : {
     581             : 
     582           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     583           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     584             : 
     585           0 :     m_bEOF = sal_False;
     586             : 
     587           0 :     m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
     588           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     589           0 :     sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     590           0 :     if(bRet)
     591           0 :         --m_nRowPos;
     592           0 :     else if ( m_nCurrentFetchState == SQL_NO_DATA )
     593           0 :         m_nRowPos = 0;
     594           0 :     return bRet;
     595             : }
     596             : 
     597           0 : Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement(  ) throw(SQLException, RuntimeException, std::exception)
     598             : {
     599           0 :     return NULL;
     600             : }
     601             : 
     602             : 
     603           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted(  ) throw(SQLException, RuntimeException, std::exception)
     604             : {
     605             : 
     606           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     607           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     608             : 
     609             : 
     610           0 :     return m_pRowStatusArray[0] == SQL_ROW_DELETED;
     611             : }
     612             : 
     613           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted(  ) throw(SQLException, RuntimeException, std::exception)
     614             : {
     615           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     616           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     617             : 
     618             : 
     619           0 :     return m_pRowStatusArray[0] == SQL_ROW_ADDED;
     620             : }
     621             : 
     622           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated(  ) throw(SQLException, RuntimeException, std::exception)
     623             : {
     624             : 
     625           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     626           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     627             : 
     628             : 
     629           0 :     return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
     630             : }
     631             : 
     632             : 
     633           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst(  ) throw(SQLException, RuntimeException, std::exception)
     634             : {
     635             : 
     636           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     637           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     638             : 
     639             : 
     640           0 :     return m_nRowPos == 0;
     641             : }
     642             : 
     643             : 
     644           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next(  ) throw(SQLException, RuntimeException, std::exception)
     645             : {
     646             : 
     647           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     648           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     649             : 
     650           0 :     m_bEOF = sal_False;
     651             : 
     652           0 :     SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
     653             :     //  m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
     654           0 :     m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
     655           0 :     OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     656           0 :     sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
     657           0 :     if(bRet || ( m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA ) )
     658           0 :         ++m_nRowPos;
     659           0 :     return bRet;
     660             : }
     661             : 
     662             : 
     663           0 : sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull(  ) throw(SQLException, RuntimeException, std::exception)
     664             : {
     665             : 
     666           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     667           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     668             : 
     669             : 
     670           0 :     return m_bWasNull;
     671             : }
     672             : 
     673           0 : void SAL_CALL ODatabaseMetaDataResultSet::refreshRow(  ) throw(SQLException, RuntimeException, std::exception)
     674             : {
     675             : 
     676           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     677           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     678             : 
     679           0 : }
     680             : 
     681             : 
     682           0 : void SAL_CALL ODatabaseMetaDataResultSet::cancel(  ) throw(RuntimeException, std::exception)
     683             : {
     684             : 
     685           0 :     checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
     686           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     687             : 
     688             : 
     689           0 :     OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     690           0 : }
     691             : 
     692           0 : void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     693             : {
     694           0 : }
     695             : 
     696           0 : Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings(  ) throw(SQLException, RuntimeException, std::exception)
     697             : {
     698           0 :     return Any();
     699             : }
     700             : 
     701           0 : sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const throw(SQLException, RuntimeException)
     702             : {
     703           0 :     return ResultSetConcurrency::READ_ONLY;
     704             : }
     705             : 
     706           0 : sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const throw(SQLException, RuntimeException)
     707             : {
     708           0 :     return ResultSetType::FORWARD_ONLY;
     709             : }
     710             : 
     711           0 : sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const throw(SQLException, RuntimeException)
     712             : {
     713           0 :     return FetchDirection::FORWARD;
     714             : }
     715             : 
     716           0 : sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const throw(SQLException, RuntimeException)
     717             : {
     718           0 :     sal_Int32 nValue=1;
     719           0 :     return nValue;
     720             : }
     721             : 
     722           0 : OUString ODatabaseMetaDataResultSet::getCursorName() const throw(SQLException, RuntimeException)
     723             : {
     724           0 :     return OUString();
     725             : }
     726             : 
     727             : 
     728           0 : ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
     729             : {
     730             : 
     731           0 :     Sequence< com::sun::star::beans::Property > aProps(5);
     732           0 :     com::sun::star::beans::Property* pProperties = aProps.getArray();
     733           0 :     sal_Int32 nPos = 0;
     734           0 :     DECL_PROP0(CURSORNAME,          OUString);
     735           0 :     DECL_PROP0(FETCHDIRECTION,      sal_Int32);
     736           0 :     DECL_PROP0(FETCHSIZE,           sal_Int32);
     737           0 :     DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
     738           0 :     DECL_PROP0(RESULTSETTYPE,       sal_Int32);
     739             : 
     740           0 :     return new ::cppu::OPropertyArrayHelper(aProps);
     741             : }
     742             : 
     743           0 : ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
     744             : {
     745           0 :     return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
     746             : }
     747             : 
     748           0 : sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
     749             :                             Any & rConvertedValue,
     750             :                             Any & rOldValue,
     751             :                             sal_Int32 nHandle,
     752             :                             const Any& rValue )
     753             :                                 throw (::com::sun::star::lang::IllegalArgumentException)
     754             : {
     755           0 :     switch(nHandle)
     756             :     {
     757             :         case PROPERTY_ID_CURSORNAME:
     758             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     759             :         case PROPERTY_ID_RESULTSETTYPE:
     760           0 :             throw ::com::sun::star::lang::IllegalArgumentException();
     761             :         case PROPERTY_ID_FETCHDIRECTION:
     762           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
     763             :         case PROPERTY_ID_FETCHSIZE:
     764           0 :             return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
     765             :         default:
     766             :             ;
     767             :     }
     768           0 :     return sal_False;
     769             : }
     770             : 
     771           0 : void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& /*rValue*/ ) throw (Exception, std::exception)
     772             : {
     773           0 :     switch(nHandle)
     774             :     {
     775             :         case PROPERTY_ID_CURSORNAME:
     776             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     777             :         case PROPERTY_ID_RESULTSETTYPE:
     778             :         case PROPERTY_ID_FETCHDIRECTION:
     779             :         case PROPERTY_ID_FETCHSIZE:
     780           0 :             throw Exception();
     781             :         default:
     782             :             OSL_FAIL("setFastPropertyValue_NoBroadcast: Illegal handle value!");
     783             :     }
     784           0 : }
     785             : 
     786           0 : void ODatabaseMetaDataResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
     787             : {
     788           0 :     switch(nHandle)
     789             :     {
     790             :         case PROPERTY_ID_CURSORNAME:
     791           0 :             rValue <<= getCursorName();
     792           0 :             break;
     793             :         case PROPERTY_ID_RESULTSETCONCURRENCY:
     794           0 :             rValue <<= getResultSetConcurrency();
     795           0 :             break;
     796             :         case PROPERTY_ID_RESULTSETTYPE:
     797           0 :             rValue <<= getResultSetType();
     798           0 :             break;
     799             :         case PROPERTY_ID_FETCHDIRECTION:
     800           0 :             rValue <<= getFetchDirection();
     801           0 :             break;
     802             :         case PROPERTY_ID_FETCHSIZE:
     803           0 :             rValue <<= getFetchSize();
     804           0 :             break;
     805             :     }
     806           0 : }
     807             : 
     808           0 : void ODatabaseMetaDataResultSet::openTypeInfo() throw(SQLException, RuntimeException)
     809             : {
     810           0 :     TInt2IntMap aMap;
     811           0 :     aMap[SQL_BIT]               = DataType::BIT;
     812           0 :     aMap[SQL_TINYINT]           = DataType::TINYINT;
     813           0 :     aMap[SQL_SMALLINT]          = DataType::SMALLINT;
     814           0 :     aMap[SQL_INTEGER]           = DataType::INTEGER;
     815           0 :     aMap[SQL_FLOAT]             = DataType::FLOAT;
     816           0 :     aMap[SQL_REAL]              = DataType::REAL;
     817           0 :     aMap[SQL_DOUBLE]            = DataType::DOUBLE;
     818           0 :     aMap[SQL_BIGINT]            = DataType::BIGINT;
     819             : 
     820           0 :     aMap[SQL_CHAR]              = DataType::CHAR;
     821           0 :     aMap[SQL_WCHAR]             = DataType::CHAR;
     822           0 :     aMap[SQL_VARCHAR]           = DataType::VARCHAR;
     823           0 :     aMap[SQL_WVARCHAR]          = DataType::VARCHAR;
     824           0 :     aMap[SQL_LONGVARCHAR]       = DataType::LONGVARCHAR;
     825           0 :     aMap[SQL_WLONGVARCHAR]      = DataType::LONGVARCHAR;
     826             : 
     827           0 :     aMap[SQL_TYPE_DATE]         = DataType::DATE;
     828           0 :     aMap[SQL_DATE]              = DataType::DATE;
     829           0 :     aMap[SQL_TYPE_TIME]         = DataType::TIME;
     830           0 :     aMap[SQL_TIME]              = DataType::TIME;
     831           0 :     aMap[SQL_TYPE_TIMESTAMP]    = DataType::TIMESTAMP;
     832           0 :     aMap[SQL_TIMESTAMP]         = DataType::TIMESTAMP;
     833             : 
     834           0 :     aMap[SQL_DECIMAL]           = DataType::DECIMAL;
     835           0 :     aMap[SQL_NUMERIC]           = DataType::NUMERIC;
     836             : 
     837           0 :     aMap[SQL_BINARY]            = DataType::BINARY;
     838           0 :     aMap[SQL_VARBINARY]         = DataType::VARBINARY;
     839           0 :     aMap[SQL_LONGVARBINARY]     = DataType::LONGVARBINARY;
     840             : 
     841           0 :     aMap[SQL_GUID]              = DataType::VARBINARY;
     842             : 
     843             : 
     844           0 :     m_aValueRange[2] = aMap;
     845             : 
     846           0 :     OTools::ThrowException(m_pConnection,N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
     847           0 :     checkColumnCount();
     848           0 : }
     849             : 
     850           0 : void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const OUString& schemaPattern,
     851             :                             const OUString& tableNamePattern,
     852             :                             const Sequence< OUString >& types )  throw(SQLException, RuntimeException)
     853             : {
     854           0 :     OString aPKQ,aPKO,aPKN,aCOL;
     855           0 :     const OUString *pSchemaPat = NULL;
     856             : 
     857           0 :     if(schemaPattern != "%")
     858           0 :         pSchemaPat = &schemaPattern;
     859             :     else
     860           0 :         pSchemaPat = NULL;
     861             : 
     862           0 :     if ( catalog.hasValue() )
     863           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
     864           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
     865           0 :     aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding);
     866             : 
     867           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
     868           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
     869           0 :                 *pPKN = aPKN.getStr();
     870             : 
     871             : 
     872           0 :     const char  *pCOL = NULL;
     873           0 :     const char* pComma = ",";
     874           0 :     const OUString* pBegin = types.getConstArray();
     875           0 :     const OUString* pEnd = pBegin + types.getLength();
     876           0 :     for(;pBegin != pEnd;++pBegin)
     877             :     {
     878           0 :         aCOL += OUStringToOString(*pBegin,m_nTextEncoding);
     879           0 :         aCOL += pComma;
     880             :     }
     881           0 :     if ( !aCOL.isEmpty() )
     882             :     {
     883           0 :         aCOL = aCOL.replaceAt(aCOL.getLength()-1,1,pComma);
     884           0 :         pCOL = aCOL.getStr();
     885             :     }
     886             :     else
     887           0 :         pCOL = SQL_ALL_TABLE_TYPES;
     888             : 
     889           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     890             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
     891             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
     892             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
     893             :                             (SDB_ODBC_CHAR *) pCOL, pCOL ? SQL_NTS : 0);
     894           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     895           0 :     checkColumnCount();
     896             : 
     897           0 : }
     898             : 
     899           0 : void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
     900             : {
     901           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     902             :                             0,0,
     903             :                             0,0,
     904             :                             0,0,
     905             :                             (SDB_ODBC_CHAR *) SQL_ALL_TABLE_TYPES,SQL_NTS);
     906           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     907             : 
     908           0 :     m_aColMapping.clear();
     909           0 :     m_aColMapping.push_back(-1);
     910           0 :     m_aColMapping.push_back(4);
     911           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     912           0 :     checkColumnCount();
     913           0 : }
     914             : 
     915           0 : void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
     916             : {
     917           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     918             :                             (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
     919             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     920             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     921             :                             (SDB_ODBC_CHAR *) "",SQL_NTS);
     922             : 
     923           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     924             : 
     925           0 :     m_aColMapping.clear();
     926           0 :     m_aColMapping.push_back(-1);
     927           0 :     m_aColMapping.push_back(1);
     928           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     929           0 :     checkColumnCount();
     930           0 : }
     931             : 
     932           0 : void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
     933             : {
     934           0 :     SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
     935             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     936             :                             (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
     937             :                             (SDB_ODBC_CHAR *) "",SQL_NTS,
     938             :                             (SDB_ODBC_CHAR *) "",SQL_NTS);
     939           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     940             : 
     941           0 :     m_aColMapping.clear();
     942           0 :     m_aColMapping.push_back(-1);
     943           0 :     m_aColMapping.push_back(2);
     944           0 :     m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
     945           0 :     checkColumnCount();
     946           0 : }
     947             : 
     948           0 : void ODatabaseMetaDataResultSet::openColumnPrivileges(  const Any& catalog, const OUString& schema,
     949             :                                         const OUString& table,   const OUString& columnNamePattern )
     950             :                                         throw(SQLException, RuntimeException)
     951             : {
     952           0 :     const OUString *pSchemaPat = NULL;
     953             : 
     954           0 :     if(schema != "%")
     955           0 :         pSchemaPat = &schema;
     956             :     else
     957           0 :         pSchemaPat = NULL;
     958             : 
     959           0 :     OString aPKQ,aPKO,aPKN,aCOL;
     960             : 
     961           0 :     if ( catalog.hasValue() )
     962           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
     963           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
     964           0 :     aPKN = OUStringToOString(table,m_nTextEncoding);
     965           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
     966             : 
     967           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
     968           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
     969           0 :                 *pPKN = aPKN.getStr(),
     970           0 :                 *pCOL = aCOL.getStr();
     971             : 
     972             : 
     973           0 :     SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle,
     974             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
     975             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
     976             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
     977             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
     978           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
     979             : 
     980           0 :     checkColumnCount();
     981           0 : }
     982             : 
     983           0 : void ODatabaseMetaDataResultSet::openColumns(   const Any& catalog,             const OUString& schemaPattern,
     984             :                                 const OUString& tableNamePattern,    const OUString& columnNamePattern )
     985             :                                 throw(SQLException, RuntimeException)
     986             : {
     987           0 :     const OUString *pSchemaPat = NULL;
     988             : 
     989           0 :     if(schemaPattern != "%")
     990           0 :         pSchemaPat = &schemaPattern;
     991             :     else
     992           0 :         pSchemaPat = NULL;
     993             : 
     994           0 :     OString aPKQ,aPKO,aPKN,aCOL;
     995           0 :     if ( catalog.hasValue() )
     996           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
     997           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
     998           0 :     aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding);
     999           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
    1000             : 
    1001           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1002           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1003           0 :                 *pPKN = aPKN.getStr(),
    1004           0 :                 *pCOL = aCOL.getStr();
    1005             : 
    1006             : 
    1007           0 :     SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle,
    1008             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1009             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
    1010             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1011             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
    1012             : 
    1013           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1014           0 :     TInt2IntMap aMap;
    1015           0 :     aMap[SQL_BIT]               = DataType::BIT;
    1016           0 :     aMap[SQL_TINYINT]           = DataType::TINYINT;
    1017           0 :     aMap[SQL_SMALLINT]          = DataType::SMALLINT;
    1018           0 :     aMap[SQL_INTEGER]           = DataType::INTEGER;
    1019           0 :     aMap[SQL_FLOAT]             = DataType::FLOAT;
    1020           0 :     aMap[SQL_REAL]              = DataType::REAL;
    1021           0 :     aMap[SQL_DOUBLE]            = DataType::DOUBLE;
    1022           0 :     aMap[SQL_BIGINT]            = DataType::BIGINT;
    1023             : 
    1024           0 :     aMap[SQL_CHAR]              = DataType::CHAR;
    1025           0 :     aMap[SQL_WCHAR]             = DataType::CHAR;
    1026           0 :     aMap[SQL_VARCHAR]           = DataType::VARCHAR;
    1027           0 :     aMap[SQL_WVARCHAR]          = DataType::VARCHAR;
    1028           0 :     aMap[SQL_LONGVARCHAR]       = DataType::LONGVARCHAR;
    1029           0 :     aMap[SQL_WLONGVARCHAR]      = DataType::LONGVARCHAR;
    1030             : 
    1031           0 :     aMap[SQL_TYPE_DATE]         = DataType::DATE;
    1032           0 :     aMap[SQL_DATE]              = DataType::DATE;
    1033           0 :     aMap[SQL_TYPE_TIME]         = DataType::TIME;
    1034           0 :     aMap[SQL_TIME]              = DataType::TIME;
    1035           0 :     aMap[SQL_TYPE_TIMESTAMP]    = DataType::TIMESTAMP;
    1036           0 :     aMap[SQL_TIMESTAMP]         = DataType::TIMESTAMP;
    1037             : 
    1038           0 :     aMap[SQL_DECIMAL]           = DataType::DECIMAL;
    1039           0 :     aMap[SQL_NUMERIC]           = DataType::NUMERIC;
    1040             : 
    1041           0 :     aMap[SQL_BINARY]            = DataType::BINARY;
    1042           0 :     aMap[SQL_VARBINARY]         = DataType::VARBINARY;
    1043           0 :     aMap[SQL_LONGVARBINARY]     = DataType::LONGVARBINARY;
    1044             : 
    1045           0 :     aMap[SQL_GUID]              = DataType::VARBINARY;
    1046             : 
    1047           0 :     m_aValueRange[5] = aMap;
    1048           0 :     checkColumnCount();
    1049           0 : }
    1050             : 
    1051           0 : void ODatabaseMetaDataResultSet::openProcedureColumns(  const Any& catalog,     const OUString& schemaPattern,
    1052             :                                 const OUString& procedureNamePattern,const OUString& columnNamePattern )
    1053             :                                 throw(SQLException, RuntimeException)
    1054             : {
    1055           0 :     const OUString *pSchemaPat = NULL;
    1056             : 
    1057           0 :     if(schemaPattern != "%")
    1058           0 :         pSchemaPat = &schemaPattern;
    1059             :     else
    1060           0 :         pSchemaPat = NULL;
    1061             : 
    1062           0 :     OString aPKQ,aPKO,aPKN,aCOL;
    1063           0 :     if ( catalog.hasValue() )
    1064           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1065           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1066           0 :     aPKN = OUStringToOString(procedureNamePattern,m_nTextEncoding);
    1067           0 :     aCOL = OUStringToOString(columnNamePattern,m_nTextEncoding);
    1068             : 
    1069           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1070           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1071           0 :                 *pPKN = aPKN.getStr(),
    1072           0 :                 *pCOL = aCOL.getStr();
    1073             : 
    1074             : 
    1075           0 :     SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle,
    1076             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1077             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1078             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1079             :                             (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
    1080             : 
    1081           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1082           0 :     checkColumnCount();
    1083           0 : }
    1084             : 
    1085           0 : void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const OUString& schemaPattern,
    1086             :                                 const OUString& procedureNamePattern)
    1087             :                                 throw(SQLException, RuntimeException)
    1088             : {
    1089           0 :     const OUString *pSchemaPat = NULL;
    1090             : 
    1091           0 :     if(schemaPattern != "%")
    1092           0 :         pSchemaPat = &schemaPattern;
    1093             :     else
    1094           0 :         pSchemaPat = NULL;
    1095             : 
    1096           0 :     OString aPKQ,aPKO,aPKN;
    1097             : 
    1098           0 :     if ( catalog.hasValue() )
    1099           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1100           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1101           0 :     aPKN = OUStringToOString(procedureNamePattern,m_nTextEncoding);
    1102             : 
    1103           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1104           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1105           0 :                 *pPKN = aPKN.getStr();
    1106             : 
    1107             : 
    1108           0 :     SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle,
    1109             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1110             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1111             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1112           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1113           0 :     checkColumnCount();
    1114           0 : }
    1115             : 
    1116           0 : void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& catalog, const OUString& schema,
    1117             :                                     const OUString& table,sal_Int32 scope,   sal_Bool nullable )
    1118             :                                     throw(SQLException, RuntimeException)
    1119             : {
    1120             :     // Some ODBC drivers really don't like getting an empty string as tableName
    1121             :     // E.g. psqlodbc up to at least version 09.01.0100 segfaults
    1122           0 :     if (table.isEmpty())
    1123             :     {
    1124           0 :         const char errMsg[] = "ODBC: Trying to get special columns of empty table name";
    1125           0 :         const char SQLState[] = "HY009";
    1126           0 :         throw SQLException( OUString(errMsg, sizeof(errMsg) - sizeof(errMsg[0]), RTL_TEXTENCODING_ASCII_US),
    1127             :                             *this,
    1128           0 :                             OUString(SQLState, sizeof(SQLState) - sizeof(SQLState[0]), RTL_TEXTENCODING_ASCII_US),
    1129             :                             -1,
    1130           0 :                             Any() );
    1131             :     }
    1132             : 
    1133           0 :     const OUString *pSchemaPat = NULL;
    1134             : 
    1135           0 :     if(schema != "%")
    1136           0 :         pSchemaPat = &schema;
    1137             :     else
    1138           0 :         pSchemaPat = NULL;
    1139             : 
    1140           0 :     OString aPKQ,aPKO,aPKN;
    1141           0 :     if ( catalog.hasValue() )
    1142           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1143           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1144           0 :     aPKN = OUStringToOString(table,m_nTextEncoding);
    1145             : 
    1146           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1147           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1148           0 :                 *pPKN = aPKN.getStr();
    1149             : 
    1150             : 
    1151           0 :     SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID,
    1152             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1153             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1154             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1155             :                             (SQLSMALLINT)scope,
    1156             :                             nullable ? SQL_NULLABLE : SQL_NO_NULLS);
    1157           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1158           0 :     checkColumnCount();
    1159           0 : }
    1160             : 
    1161           0 : void ODatabaseMetaDataResultSet::openVersionColumns(const Any& catalog, const OUString& schema,
    1162             :                                     const OUString& table)  throw(SQLException, RuntimeException)
    1163             : {
    1164           0 :     openSpecialColumns(sal_True,catalog,schema,table,SQL_SCOPE_TRANSACTION,sal_False);
    1165           0 : }
    1166             : 
    1167           0 : void ODatabaseMetaDataResultSet::openBestRowIdentifier( const Any& catalog, const OUString& schema,
    1168             :                                         const OUString& table,sal_Int32 scope,sal_Bool nullable ) throw(SQLException, RuntimeException)
    1169             : {
    1170           0 :     openSpecialColumns(sal_False,catalog,schema,table,scope,nullable);
    1171           0 : }
    1172             : 
    1173           0 : void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const OUString* schema,
    1174             :                                   const OUString* table,
    1175             :                                   const Any& catalog2, const OUString* schema2,
    1176             :                                   const OUString* table2) throw(SQLException, RuntimeException)
    1177             : {
    1178           0 :     OString aPKQ, aPKN, aFKQ, aFKO, aFKN;
    1179           0 :     if ( catalog.hasValue() )
    1180           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1181           0 :     if ( catalog2.hasValue() )
    1182           0 :         aFKQ = OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
    1183             : 
    1184           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1185           0 :                 *pPKO = schema && !schema->isEmpty() ? OUStringToOString(*schema,m_nTextEncoding).getStr() : NULL,
    1186           0 :                 *pPKN = table   ? (aPKN = OUStringToOString(*table,m_nTextEncoding)).getStr(): NULL,
    1187           0 :                 *pFKQ = catalog2.hasValue() && !aFKQ.isEmpty() ? aFKQ.getStr() : NULL,
    1188           0 :                 *pFKO = schema2 && !schema2->isEmpty() ? (aFKO = OUStringToOString(*schema2,m_nTextEncoding)).getStr() : NULL,
    1189           0 :                 *pFKN = table2  ? (aFKN = OUStringToOString(*table2,m_nTextEncoding)).getStr() : NULL;
    1190             : 
    1191             : 
    1192           0 :     SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle,
    1193             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1194             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
    1195             :                             (SDB_ODBC_CHAR *) pPKN, pPKN ? SQL_NTS : 0,
    1196             :                             (SDB_ODBC_CHAR *) pFKQ, (catalog2.hasValue() && !aFKQ.isEmpty()) ? SQL_NTS : 0,
    1197             :                             (SDB_ODBC_CHAR *) pFKO, pFKO ? SQL_NTS : 0,
    1198             :                             (SDB_ODBC_CHAR *) pFKN, SQL_NTS
    1199             :                             );
    1200           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1201           0 :     checkColumnCount();
    1202           0 : }
    1203             : 
    1204           0 : void ODatabaseMetaDataResultSet::openImportedKeys(const Any& catalog, const OUString& schema,
    1205             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1206             : {
    1207             : 
    1208           0 :     openForeignKeys(Any(),NULL,NULL,catalog, schema.equalsAscii("%") ? &schema : NULL, &table);
    1209           0 : }
    1210             : 
    1211           0 : void ODatabaseMetaDataResultSet::openExportedKeys(const Any& catalog, const OUString& schema,
    1212             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1213             : {
    1214           0 :     openForeignKeys(catalog, schema.equalsAscii("%") ? &schema : NULL, &table,Any(),NULL,NULL);
    1215           0 : }
    1216             : 
    1217           0 : void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const OUString& schema,
    1218             :                                   const OUString& table) throw(SQLException, RuntimeException)
    1219             : {
    1220           0 :     const OUString *pSchemaPat = NULL;
    1221             : 
    1222           0 :     if(schema != "%")
    1223           0 :         pSchemaPat = &schema;
    1224             :     else
    1225           0 :         pSchemaPat = NULL;
    1226             : 
    1227           0 :     OString aPKQ,aPKO,aPKN;
    1228             : 
    1229           0 :     if ( catalog.hasValue() )
    1230           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1231           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1232             : 
    1233           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1234           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1235           0 :                 *pPKN = (aPKN = OUStringToOString(table,m_nTextEncoding)).getStr();
    1236             : 
    1237             : 
    1238           0 :     SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle,
    1239             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1240             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1241             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1242           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1243           0 :     checkColumnCount();
    1244           0 : }
    1245             : 
    1246           0 : void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const OUString& schemaPattern,
    1247             :                                   const OUString& tableNamePattern) throw(SQLException, RuntimeException)
    1248             : {
    1249           0 :     const OUString *pSchemaPat = NULL;
    1250             : 
    1251           0 :     if(schemaPattern != "%")
    1252           0 :         pSchemaPat = &schemaPattern;
    1253             :     else
    1254           0 :         pSchemaPat = NULL;
    1255             : 
    1256           0 :     OString aPKQ,aPKO,aPKN;
    1257             : 
    1258           0 :     if ( catalog.hasValue() )
    1259           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1260           0 :     aPKO = OUStringToOString(schemaPattern,m_nTextEncoding);
    1261             : 
    1262           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1263           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1264           0 :                 *pPKN = (aPKN = OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr();
    1265             : 
    1266             : 
    1267           0 :     SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle,
    1268             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1269             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1270             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
    1271           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1272           0 :     checkColumnCount();
    1273           0 : }
    1274             : 
    1275           0 : void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const OUString& schema,
    1276             :                                 const OUString& table,sal_Bool unique,sal_Bool approximate )
    1277             :                                 throw(SQLException, RuntimeException)
    1278             : {
    1279           0 :     const OUString *pSchemaPat = NULL;
    1280             : 
    1281           0 :     if(schema != "%")
    1282           0 :         pSchemaPat = &schema;
    1283             :     else
    1284           0 :         pSchemaPat = NULL;
    1285             : 
    1286           0 :     OString aPKQ,aPKO,aPKN;
    1287             : 
    1288           0 :     if ( catalog.hasValue() )
    1289           0 :         aPKQ = OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
    1290           0 :     aPKO = OUStringToOString(schema,m_nTextEncoding);
    1291             : 
    1292           0 :     const char  *pPKQ = catalog.hasValue() && !aPKQ.isEmpty() ? aPKQ.getStr()  : NULL,
    1293           0 :                 *pPKO = pSchemaPat && !pSchemaPat->isEmpty() && !aPKO.isEmpty() ? aPKO.getStr() : NULL,
    1294           0 :                 *pPKN = (aPKN = OUStringToOString(table,m_nTextEncoding)).getStr();
    1295             : 
    1296             : 
    1297           0 :     SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle,
    1298             :                             (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && !aPKQ.isEmpty()) ? SQL_NTS : 0,
    1299             :                             (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
    1300             :                             (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
    1301             :                             unique ? SQL_INDEX_UNIQUE : SQL_INDEX_ALL,
    1302             :                             approximate);
    1303           0 :     OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1304           0 :     checkColumnCount();
    1305           0 : }
    1306             : 
    1307           0 : void ODatabaseMetaDataResultSet::checkColumnCount()
    1308             : {
    1309           0 :     sal_Int16 nNumResultCols=0;
    1310           0 :     OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
    1311           0 :     m_nDriverColumnCount = nNumResultCols;
    1312           0 : }
    1313             : 
    1314             : 
    1315           0 : SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
    1316             : {
    1317           0 :     ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
    1318           0 :     if ( aFind == m_aODBCColumnTypes.end() )
    1319           0 :         aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first;
    1320           0 :     return aFind->second;
    1321             : }
    1322             : 
    1323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10