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