LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/commontools - dbexception.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 223 0.0 %
Date: 2012-12-27 Functions: 0 37 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 <connectivity/dbexception.hxx>
      21             : #include <comphelper/types.hxx>
      22             : #include <cppuhelper/exc_hlp.hxx>
      23             : #include <osl/diagnose.h>
      24             : #include <com/sun/star/sdb/SQLContext.hpp>
      25             : #include <com/sun/star/sdbc/SQLWarning.hpp>
      26             : #include <com/sun/star/sdb/SQLErrorEvent.hpp>
      27             : #include "TConnection.hxx"
      28             : #include "resource/common_res.hrc"
      29             : #include "resource/sharedresources.hxx"
      30             : 
      31             : //.........................................................................
      32             : namespace dbtools
      33             : {
      34             : //.........................................................................
      35             : 
      36             :     using namespace ::com::sun::star::uno;
      37             :     using namespace ::com::sun::star::sdb;
      38             :     using namespace ::com::sun::star::sdbc;
      39             :     using namespace ::comphelper;
      40             :     using namespace ::connectivity;
      41             : 
      42             : //==============================================================================
      43             : //= SQLExceptionInfo - encapsulating the type info of an SQLException-derived class
      44             : //==============================================================================
      45             : //------------------------------------------------------------------------------
      46           0 : SQLExceptionInfo::SQLExceptionInfo()
      47           0 :     :m_eType(UNDEFINED)
      48             : {
      49           0 : }
      50             : 
      51             : //------------------------------------------------------------------------------
      52           0 : SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdbc::SQLException& _rError)
      53             : {
      54           0 :     m_aContent <<= _rError;
      55           0 :     implDetermineType();
      56           0 : }
      57             : 
      58             : //------------------------------------------------------------------------------
      59           0 : SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdbc::SQLWarning& _rError)
      60             : {
      61           0 :     m_aContent <<= _rError;
      62           0 :     implDetermineType();
      63           0 : }
      64             : 
      65             : //------------------------------------------------------------------------------
      66           0 : SQLExceptionInfo::SQLExceptionInfo(const ::com::sun::star::sdb::SQLContext& _rError)
      67             : {
      68           0 :     m_aContent <<= _rError;
      69           0 :     implDetermineType();
      70           0 : }
      71             : 
      72             : //------------------------------------------------------------------------------
      73           0 : SQLExceptionInfo::SQLExceptionInfo( const ::rtl::OUString& _rSimpleErrorMessage )
      74             : {
      75           0 :     SQLException aError;
      76           0 :     aError.Message = _rSimpleErrorMessage;
      77           0 :     m_aContent <<= aError;
      78           0 :     implDetermineType();
      79           0 : }
      80             : 
      81             : //------------------------------------------------------------------------------
      82           0 : SQLExceptionInfo::SQLExceptionInfo(const SQLExceptionInfo& _rCopySource)
      83             :     :m_aContent(_rCopySource.m_aContent)
      84           0 :     ,m_eType(_rCopySource.m_eType)
      85             : {
      86           0 : }
      87             : 
      88             : //------------------------------------------------------------------------------
      89           0 : const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdbc::SQLException& _rError)
      90             : {
      91           0 :     m_aContent <<= _rError;
      92           0 :     implDetermineType();
      93           0 :     return *this;
      94             : }
      95             : 
      96             : //------------------------------------------------------------------------------
      97           0 : const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdbc::SQLWarning& _rError)
      98             : {
      99           0 :     m_aContent <<= _rError;
     100           0 :     implDetermineType();
     101           0 :     return *this;
     102             : }
     103             : 
     104             : //------------------------------------------------------------------------------
     105           0 : const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdb::SQLContext& _rError)
     106             : {
     107           0 :     m_aContent <<= _rError;
     108           0 :     implDetermineType();
     109           0 :     return *this;
     110             : }
     111             : 
     112             : //------------------------------------------------------------------------------
     113           0 : const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::sdb::SQLErrorEvent& _rErrorEvent)
     114             : {
     115           0 :     m_aContent = _rErrorEvent.Reason;
     116           0 :     implDetermineType();
     117           0 :     return *this;
     118             : }
     119             : 
     120             : //------------------------------------------------------------------------------
     121           0 : const SQLExceptionInfo& SQLExceptionInfo::operator=(const ::com::sun::star::uno::Any& _rCaughtSQLException)
     122             : {
     123           0 :     m_aContent = _rCaughtSQLException;
     124           0 :     implDetermineType();
     125           0 :     return *this;
     126             : }
     127             : 
     128             : //------------------------------------------------------------------------------
     129           0 : SQLExceptionInfo::SQLExceptionInfo(const staruno::Any& _rError)
     130             : {
     131           0 :     const staruno::Type& aSQLExceptionType = ::getCppuType(static_cast< ::com::sun::star::sdbc::SQLException*>(0));
     132           0 :     sal_Bool bValid = isAssignableFrom(aSQLExceptionType, _rError.getValueType());
     133           0 :     if (bValid)
     134           0 :         m_aContent = _rError;
     135             :     // no assertion here : if used with the NextException member of an SQLException bValid==sal_False is allowed.
     136             : 
     137           0 :     implDetermineType();
     138           0 : }
     139             : 
     140             : //------------------------------------------------------------------------------
     141           0 : void SQLExceptionInfo::implDetermineType()
     142             : {
     143           0 :     staruno::Type aContentType = m_aContent.getValueType();
     144             : 
     145           0 :     const Type& aSQLExceptionType = ::getCppuType( static_cast< SQLException* >( 0 ) );
     146           0 :     const Type& aSQLWarningType = ::getCppuType( static_cast< SQLWarning* >( 0 ) );
     147           0 :     const Type& aSQLContextType  = ::getCppuType( static_cast< SQLContext* >( 0 ) );
     148             : 
     149           0 :     if ( isAssignableFrom( aSQLContextType, m_aContent.getValueType() ) )
     150           0 :         m_eType = SQL_CONTEXT;
     151           0 :     else if ( isAssignableFrom( aSQLWarningType, m_aContent.getValueType() ) )
     152           0 :         m_eType = SQL_WARNING;
     153           0 :     else if ( isAssignableFrom( aSQLExceptionType, m_aContent.getValueType() ) )
     154           0 :         m_eType = SQL_EXCEPTION;
     155             :     else
     156             :     {
     157           0 :         m_eType = UNDEFINED;
     158           0 :         m_aContent.clear();
     159           0 :     }
     160           0 : }
     161             : 
     162             : //------------------------------------------------------------------------------
     163           0 : sal_Bool SQLExceptionInfo::isKindOf(TYPE _eType) const
     164             : {
     165           0 :     switch (_eType)
     166             :     {
     167             :         case SQL_CONTEXT:
     168           0 :             return (m_eType == SQL_CONTEXT);
     169             :         case SQL_WARNING:
     170           0 :             return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING);
     171             :         case SQL_EXCEPTION:
     172           0 :             return (m_eType == SQL_CONTEXT) || (m_eType == SQL_WARNING) || (m_eType == SQL_EXCEPTION);
     173             :         case UNDEFINED:
     174           0 :             return (m_eType == UNDEFINED);
     175             :     }
     176           0 :     return sal_False;
     177             : }
     178             : 
     179             : //------------------------------------------------------------------------------
     180           0 : SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLException*() const
     181             : {
     182             :     OSL_ENSURE(isKindOf(SQL_EXCEPTION), "SQLExceptionInfo::operator SQLException* : invalid call !");
     183           0 :     return reinterpret_cast<const ::com::sun::star::sdbc::SQLException*>(m_aContent.getValue());
     184             : }
     185             : 
     186             : //------------------------------------------------------------------------------
     187           0 : SQLExceptionInfo::operator const ::com::sun::star::sdbc::SQLWarning*() const
     188             : {
     189             :     OSL_ENSURE(isKindOf(SQL_WARNING), "SQLExceptionInfo::operator SQLException* : invalid call !");
     190           0 :     return reinterpret_cast<const ::com::sun::star::sdbc::SQLWarning*>(m_aContent.getValue());
     191             : }
     192             : 
     193             : //------------------------------------------------------------------------------
     194           0 : SQLExceptionInfo::operator const ::com::sun::star::sdb::SQLContext*() const
     195             : {
     196             :     OSL_ENSURE(isKindOf(SQL_CONTEXT), "SQLExceptionInfo::operator SQLException* : invalid call !");
     197           0 :     return reinterpret_cast<const ::com::sun::star::sdb::SQLContext*>(m_aContent.getValue());
     198             : }
     199             : 
     200             : //------------------------------------------------------------------------------
     201           0 : void SQLExceptionInfo::prepend( const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState, const sal_Int32 _nErrorCode )
     202             : {
     203           0 :     SQLException aException;
     204           0 :     aException.Message = _rErrorMessage;
     205           0 :     aException.ErrorCode = _nErrorCode;
     206           0 :     aException.SQLState = _pAsciiSQLState ? ::rtl::OUString::createFromAscii( _pAsciiSQLState ) : ::rtl::OUString("S1000" );
     207           0 :     aException.NextException = m_aContent;
     208           0 :     m_aContent <<= aException;
     209             : 
     210           0 :     m_eType = SQL_EXCEPTION;
     211           0 : }
     212             : 
     213             : //------------------------------------------------------------------------------
     214           0 : void SQLExceptionInfo::append( TYPE _eType, const ::rtl::OUString& _rErrorMessage, const sal_Char* _pAsciiSQLState, const sal_Int32 _nErrorCode )
     215             : {
     216             :     // create the to-be-appended exception
     217           0 :     Any aAppend;
     218           0 :     switch ( _eType )
     219             :     {
     220           0 :     case SQL_EXCEPTION: aAppend <<= SQLException(); break;
     221           0 :     case SQL_WARNING:   aAppend <<= SQLWarning();   break;
     222           0 :     case SQL_CONTEXT:   aAppend <<= SQLContext();   break;
     223             :     default:
     224             :         OSL_FAIL( "SQLExceptionInfo::append: invalid exception type: this will crash!" );
     225           0 :         break;
     226             :     }
     227             : 
     228           0 :     SQLException* pAppendException( static_cast< SQLException* >( const_cast< void* >( aAppend.getValue() ) ) );
     229           0 :     pAppendException->Message = _rErrorMessage;
     230           0 :     pAppendException->SQLState = ::rtl::OUString::createFromAscii( _pAsciiSQLState );
     231           0 :     pAppendException->ErrorCode = _nErrorCode;
     232             : 
     233             :     // find the end of the current chain
     234           0 :     Any* pChainIterator = &m_aContent;
     235           0 :     SQLException* pLastException = NULL;
     236           0 :     const Type& aSQLExceptionType( ::getCppuType< SQLException >() );
     237           0 :     while ( pChainIterator )
     238             :     {
     239           0 :         if ( !pChainIterator->hasValue() )
     240           0 :             break;
     241             : 
     242           0 :         if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) )
     243           0 :             break;
     244             : 
     245           0 :         pLastException = static_cast< SQLException* >( const_cast< void* >( pChainIterator->getValue() ) );
     246           0 :         pChainIterator = &pLastException->NextException;
     247             :     }
     248             : 
     249             :     // append
     250           0 :     if ( pLastException )
     251           0 :         pLastException->NextException = aAppend;
     252             :     else
     253             :     {
     254           0 :         m_aContent = aAppend;
     255           0 :         m_eType = _eType;
     256           0 :     }
     257           0 : }
     258             : 
     259             : //------------------------------------------------------------------------------
     260           0 : void SQLExceptionInfo::doThrow()
     261             : {
     262           0 :     if ( m_aContent.getValueTypeClass() == TypeClass_EXCEPTION )
     263           0 :         ::cppu::throwException( m_aContent );
     264           0 :     throw RuntimeException();
     265             : }
     266             : 
     267             : //==============================================================================
     268             : //= SQLExceptionIteratorHelper
     269             : //==============================================================================
     270             : 
     271             : //------------------------------------------------------------------------------
     272           0 : SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const SQLExceptionInfo& _rChainStart )
     273             :     :m_pCurrent( NULL )
     274           0 :     ,m_eCurrentType( SQLExceptionInfo::UNDEFINED )
     275             : {
     276           0 :     if ( _rChainStart.isValid() )
     277             :     {
     278           0 :         m_pCurrent = (const SQLException*)_rChainStart;
     279           0 :         m_eCurrentType = _rChainStart.getType();
     280             :     }
     281           0 : }
     282             : 
     283             : //------------------------------------------------------------------------------
     284           0 : SQLExceptionIteratorHelper::SQLExceptionIteratorHelper( const ::com::sun::star::sdbc::SQLException& _rChainStart )
     285             :     :m_pCurrent( &_rChainStart )
     286           0 :     ,m_eCurrentType( SQLExceptionInfo::SQL_EXCEPTION )
     287             : {
     288           0 : }
     289             : 
     290             : //------------------------------------------------------------------------------
     291           0 : void SQLExceptionIteratorHelper::current( SQLExceptionInfo& _out_rInfo ) const
     292             : {
     293           0 :     switch ( m_eCurrentType )
     294             :     {
     295             :     case SQLExceptionInfo::SQL_EXCEPTION:
     296           0 :         _out_rInfo = *m_pCurrent;
     297           0 :         break;
     298             : 
     299             :     case SQLExceptionInfo::SQL_WARNING:
     300           0 :         _out_rInfo = *static_cast< const SQLWarning* >( m_pCurrent );
     301           0 :         break;
     302             : 
     303             :     case SQLExceptionInfo::SQL_CONTEXT:
     304           0 :         _out_rInfo = *static_cast< const SQLContext* >( m_pCurrent );
     305           0 :         break;
     306             : 
     307             :     default:
     308           0 :         _out_rInfo = Any();
     309           0 :         break;
     310             :     }
     311           0 : }
     312             : 
     313             : //------------------------------------------------------------------------------
     314           0 : const ::com::sun::star::sdbc::SQLException* SQLExceptionIteratorHelper::next()
     315             : {
     316             :     OSL_ENSURE( hasMoreElements(), "SQLExceptionIteratorHelper::next : invalid call (please use hasMoreElements)!" );
     317             : 
     318           0 :     const ::com::sun::star::sdbc::SQLException* pReturn = current();
     319           0 :     if ( !m_pCurrent )
     320           0 :         return pReturn;
     321             : 
     322             :     // check for the next element within the chain
     323           0 :     const Type aTypeException( ::cppu::UnoType< SQLException >::get() );
     324             : 
     325           0 :     Type aNextElementType = m_pCurrent->NextException.getValueType();
     326           0 :     if ( !isAssignableFrom( aTypeException, aNextElementType ) )
     327             :     {
     328             :         // no SQLException at all in the next chain element
     329           0 :         m_pCurrent = NULL;
     330           0 :         m_eCurrentType = SQLExceptionInfo::UNDEFINED;
     331           0 :         return pReturn;
     332             :     }
     333             : 
     334           0 :     m_pCurrent = static_cast< const SQLException* >( m_pCurrent->NextException.getValue() );
     335             : 
     336             :     // no finally determine the proper type of the exception
     337           0 :     const Type aTypeContext( ::cppu::UnoType< SQLContext >::get() );
     338           0 :     if ( isAssignableFrom( aTypeContext, aNextElementType ) )
     339             :     {
     340           0 :         m_eCurrentType = SQLExceptionInfo::SQL_CONTEXT;
     341           0 :         return pReturn;
     342             :     }
     343             : 
     344           0 :     const Type aTypeWarning( ::cppu::UnoType< SQLWarning >::get() );
     345           0 :     if ( isAssignableFrom( aTypeWarning, aNextElementType ) )
     346             :     {
     347           0 :         m_eCurrentType = SQLExceptionInfo::SQL_WARNING;
     348           0 :         return pReturn;
     349             :     }
     350             : 
     351             :     // a simple SQLException
     352           0 :     m_eCurrentType = SQLExceptionInfo::SQL_EXCEPTION;
     353           0 :     return pReturn;
     354             : }
     355             : 
     356             : //------------------------------------------------------------------------------
     357           0 : void SQLExceptionIteratorHelper::next( SQLExceptionInfo& _out_rInfo )
     358             : {
     359           0 :     current( _out_rInfo );
     360           0 :     next();
     361           0 : }
     362             : 
     363             : //------------------------------------------------------------
     364           0 : void throwFunctionSequenceException(const Reference< XInterface >& _Context, const Any& _Next)  throw ( ::com::sun::star::sdbc::SQLException )
     365             : {
     366           0 :     ::connectivity::SharedResources aResources;
     367             :     throw SQLException(
     368             :         aResources.getResourceString(STR_ERRORMSG_SEQUENCE),
     369             :         _Context,
     370             :         getStandardSQLState( SQL_FUNCTION_SEQUENCE_ERROR ),
     371             :         0,
     372             :         _Next
     373           0 :     );
     374             : }
     375             : // -----------------------------------------------------------------------------
     376           0 : void throwInvalidIndexException(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
     377             :         const ::com::sun::star::uno::Any& _Next)  throw ( ::com::sun::star::sdbc::SQLException )
     378             : {
     379           0 :     ::connectivity::SharedResources aResources;
     380             :     throw SQLException(
     381             :         aResources.getResourceString(STR_INVALID_INDEX),
     382             :         _Context,
     383             :         getStandardSQLState( SQL_INVALID_DESCRIPTOR_INDEX ),
     384             :         0,
     385             :         _Next
     386           0 :     );
     387             : }
     388             : // -----------------------------------------------------------------------------
     389           0 : void throwFunctionNotSupportedException(const ::rtl::OUString& _rMsg,
     390             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _Context,
     391             :         const ::com::sun::star::uno::Any& _Next)  throw ( ::com::sun::star::sdbc::SQLException )
     392             : {
     393             :     throw SQLException(
     394             :         _rMsg,
     395             :         _Context,
     396             :         getStandardSQLState( SQL_FUNCTION_NOT_SUPPORTED ),
     397             :         0,
     398             :         _Next
     399           0 :     );
     400             : }
     401             : // -----------------------------------------------------------------------------
     402           0 : void throwFunctionNotSupportedException( const sal_Char* _pAsciiFunctionName, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
     403             :         const ::com::sun::star::uno::Any* _pNextException ) throw ( ::com::sun::star::sdbc::SQLException )
     404             : {
     405           0 :     ::connectivity::SharedResources aResources;
     406             :     const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
     407             :             STR_UNSUPPORTED_FUNCTION,
     408             :             "$functionname$", ::rtl::OUString::createFromAscii( _pAsciiFunctionName )
     409           0 :          ) );
     410             :     throwFunctionNotSupportedException(
     411             :         sError,
     412             :         _rxContext,
     413             :         _pNextException ? *_pNextException : Any()
     414           0 :     );
     415           0 : }
     416             : // -----------------------------------------------------------------------------
     417           0 : void throwGenericSQLException(const ::rtl::OUString& _rMsg, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxSource)
     418             :     throw (::com::sun::star::sdbc::SQLException)
     419             : {
     420           0 :     throwGenericSQLException(_rMsg, _rxSource, Any());
     421           0 : }
     422             : 
     423             : // -----------------------------------------------------------------------------
     424           0 : void throwGenericSQLException(const ::rtl::OUString& _rMsg, const Reference< XInterface >& _rxSource, const Any& _rNextException)
     425             :     throw (SQLException)
     426             : {
     427           0 :     throw SQLException( _rMsg, _rxSource, getStandardSQLState( SQL_GENERAL_ERROR ), 0, _rNextException);
     428             : }
     429             : 
     430             : // -----------------------------------------------------------------------------
     431           0 : void throwFeatureNotImplementedException( const sal_Char* _pAsciiFeatureName, const Reference< XInterface >& _rxContext, const Any* _pNextException )
     432             :     throw (SQLException)
     433             : {
     434           0 :     ::connectivity::SharedResources aResources;
     435             :     const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
     436             :             STR_UNSUPPORTED_FEATURE,
     437             :             "$featurename$", ::rtl::OUString::createFromAscii( _pAsciiFeatureName )
     438           0 :          ) );
     439             : 
     440             :     throw SQLException(
     441             :         sError,
     442             :         _rxContext,
     443             :         getStandardSQLState( SQL_FEATURE_NOT_IMPLEMENTED ),
     444             :         0,
     445             :         _pNextException ? *_pNextException : Any()
     446           0 :     );
     447             : }
     448             : 
     449             : // -----------------------------------------------------------------------------
     450           0 : void throwSQLException( const sal_Char* _pAsciiMessage, const sal_Char* _pAsciiState,
     451             :         const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode, const Any* _pNextException ) throw (SQLException)
     452             : {
     453             :     throw SQLException(
     454             :         ::rtl::OUString::createFromAscii( _pAsciiMessage ),
     455             :         _rxContext,
     456             :         ::rtl::OUString::createFromAscii( _pAsciiState ),
     457             :         _nErrorCode,
     458             :         _pNextException ? *_pNextException : Any()
     459           0 :     );
     460             : }
     461             : 
     462             : // -----------------------------------------------------------------------------
     463           0 : void throwSQLException( const sal_Char* _pAsciiMessage, StandardSQLState _eSQLState,
     464             :         const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode,
     465             :         const Any* _pNextException ) throw (SQLException)
     466             : {
     467           0 :     throwSQLException( _pAsciiMessage, getStandardSQLStateAscii( _eSQLState ), _rxContext, _nErrorCode, _pNextException );
     468           0 : }
     469             : 
     470             : // -----------------------------------------------------------------------------
     471           0 : void throwSQLException( const ::rtl::OUString& _rMessage, StandardSQLState _eSQLState,
     472             :         const Reference< XInterface >& _rxContext, const sal_Int32 _nErrorCode,
     473             :         const Any* _pNextException ) throw (SQLException)
     474             : {
     475             :     throw SQLException(
     476             :         _rMessage,
     477             :         _rxContext,
     478             :         getStandardSQLState( _eSQLState ),
     479             :         _nErrorCode,
     480             :         _pNextException ? *_pNextException : Any()
     481           0 :     );
     482             : }
     483             : 
     484             : // -----------------------------------------------------------------------------
     485           0 : const sal_Char* getStandardSQLStateAscii( StandardSQLState _eState )
     486             : {
     487           0 :     const sal_Char* pAsciiState = NULL;
     488           0 :     switch ( _eState )
     489             :     {
     490           0 :         case SQL_WRONG_PARAMETER_NUMBER:    pAsciiState = "07001"; break;
     491           0 :         case SQL_INVALID_DESCRIPTOR_INDEX:  pAsciiState = "07009"; break;
     492           0 :         case SQL_UNABLE_TO_CONNECT:         pAsciiState = "08001"; break;
     493           0 :         case SQL_NUMERIC_OUT_OF_RANGE:      pAsciiState = "22003"; break;
     494           0 :         case SQL_INVALID_DATE_TIME:         pAsciiState = "22007"; break;
     495           0 :         case SQL_INVALID_CURSOR_STATE:      pAsciiState = "24000"; break;
     496           0 :         case SQL_TABLE_OR_VIEW_EXISTS:      pAsciiState = "42S01"; break;
     497           0 :         case SQL_TABLE_OR_VIEW_NOT_FOUND:   pAsciiState = "42S02"; break;
     498           0 :         case SQL_INDEX_ESISTS:              pAsciiState = "42S11"; break;
     499           0 :         case SQL_INDEX_NOT_FOUND:           pAsciiState = "42S12"; break;
     500           0 :         case SQL_COLUMN_EXISTS:             pAsciiState = "42S21"; break;
     501           0 :         case SQL_COLUMN_NOT_FOUND:          pAsciiState = "42S22"; break;
     502           0 :         case SQL_GENERAL_ERROR:             pAsciiState = "HY000"; break;
     503           0 :         case SQL_INVALID_SQL_DATA_TYPE:     pAsciiState = "HY004"; break;
     504           0 :         case SQL_OPERATION_CANCELED:        pAsciiState = "HY008"; break;
     505           0 :         case SQL_FUNCTION_SEQUENCE_ERROR:   pAsciiState = "HY010"; break;
     506           0 :         case SQL_INVALID_CURSOR_POSITION:   pAsciiState = "HY109"; break;
     507           0 :         case SQL_INVALID_BOOKMARK_VALUE:    pAsciiState = "HY111"; break;
     508           0 :         case SQL_FEATURE_NOT_IMPLEMENTED:   pAsciiState = "HYC00"; break;
     509           0 :         case SQL_FUNCTION_NOT_SUPPORTED:    pAsciiState = "IM001"; break;
     510           0 :         case SQL_CONNECTION_DOES_NOT_EXIST: pAsciiState = "08003"; break;
     511             : 
     512             :         default:
     513           0 :             break;
     514             :     }
     515           0 :     if ( !pAsciiState )
     516           0 :         throw RuntimeException();
     517           0 :     return pAsciiState;
     518             : }
     519             : 
     520             : // -----------------------------------------------------------------------------
     521           0 : ::rtl::OUString getStandardSQLState( StandardSQLState _eState )
     522             : {
     523           0 :     return ::rtl::OUString::createFromAscii( getStandardSQLStateAscii( _eState ) );
     524             : }
     525             : 
     526             : // -----------------------------------------------------------------------------
     527             : //.........................................................................
     528             : }   // namespace dbtools
     529             : //.........................................................................
     530             : 
     531             : 
     532             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10