diff options
Diffstat (limited to 'dbaccess/source/core/api/KeySet.cxx')
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 249 |
1 files changed, 96 insertions, 153 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index 21dc7d8443e6..f5e8e9c7df27 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,85 +29,35 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBACCESS_CORE_API_KEYSET_HXX #include "KeySet.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HXX_ #include "core_resource.hxx" -#endif -#ifndef _DBA_CORE_RESOURCE_HRC_ #include "core_resource.hrc" -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> -#endif #include <com/sun/star/sdbc/ColumnValue.hpp> -#ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_ #include <com/sun/star/sdbc/XPreparedStatement.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCxParameterS_HPP_ #include <com/sun/star/sdbc/XParameters.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XGENERATEDRESULTSET_HPP_ #include <com/sun/star/sdbc/XGeneratedResultSet.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCOLUMNLOCATE_HPP_ #include <com/sun/star/sdbc/XColumnLocate.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ #include <com/sun/star/container/XIndexAccess.hpp> -#endif -#ifndef DBACCESS_SHARED_DBASTRINGS_HRC #include "dbastrings.hrc" -#endif -#ifndef _DBASHARED_APITOOLS_HXX_ #include "apitools.hxx" -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYCOMPOSER_HPP_ #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XINDEXESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XIndexesSupplier.hpp> -#endif -#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ #include <cppuhelper/typeprovider.hxx> -#endif -#ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> -#endif #include <list> #include <algorithm> #include <string.h> -#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_ #include <com/sun/star/io/XInputStream.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#endif -#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX #include "querycomposer.hxx" -#endif -#ifndef DBACCESS_SOURCE_CORE_INC_COMPOSERTOOLS_HXX #include "composertools.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif #include <string.h> #include <rtl/logfile.hxx> #include "PrivateRow.hxx" @@ -148,7 +99,7 @@ namespace } } DBG_NAME(OKeySet) -// ------------------------------------------------------------------------- + OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, const Reference< XIndexAccess>& _xTableKeys, const ::rtl::OUString& _rUpdateTableName, // this can be the alias or the full qualified name @@ -173,20 +124,20 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable, DBG_CTOR(OKeySet,NULL); } -// ----------------------------------------------------------------------------- + OKeySet::~OKeySet() { try { ::comphelper::disposeComponent(m_xStatement); } - catch(Exception&) + catch(const Exception&) { m_xStatement = NULL; } catch(...) { - OSL_ENSURE(0,"Unknown Exception occured"); + OSL_FAIL("Unknown Exception occurred"); } m_xComposer = NULL; @@ -229,7 +180,7 @@ void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable, ::rtl::OUString sUpdateTableName( i_rUpdateTableName ); if ( sUpdateTableName.getLength() == 0 ) { - OSL_ENSURE( false, "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." ); + OSL_FAIL( "OKeySet::findTableColumnsMatching_throw: This is a fallback only - it won't work when the table has an alias name." ); // If i_aTable originates from a query composer, and is a table which appears with an alias in the SELECT statement, // then the below code will not produce correct results. // For instance, imagine a "SELECT alias.col FROM table AS alias". Now i_aTable would be the table named @@ -272,7 +223,7 @@ void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable, } ::rtl::OUStringBuffer OKeySet::createKeyFilter() { - static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); const ::rtl::OUString aQuote = getIdentifierQuoteString(); ::rtl::OUStringBuffer aFilter; static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); @@ -292,7 +243,7 @@ void OKeySet::findTableColumnsMatching_throw( const Any& i_aTable, } return aFilter; } -// ----------------------------------------------------------------------------- + void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::construct" ); @@ -321,7 +272,7 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O const Sequence< ::rtl::OUString> aSeq = xSelectTables->getElementNames(); if ( aSeq.getLength() > 1 ) // special handling for join { - static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); const ::rtl::OUString aQuote = getIdentifierQuoteString(); static ::rtl::OUString s_sDot(RTL_CONSTASCII_USTRINGPARAM(".")); static ::rtl::OUString s_sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); @@ -341,20 +292,17 @@ void OKeySet::construct(const Reference< XResultSet>& _xDriverSet,const ::rtl::O for(SelectColumnsMetaData::iterator aPosIter = (*m_pForeignColumnNames).begin();aPosIter != aPosEnd;++aPosIter) { // look for columns not in the source columns to use them as filter as well - // if ( !xSourceColumns->hasByName(aPosIter->first) ) - { if ( aFilter.getLength() ) aFilter.append(aAnd); aFilter.append(::dbtools::quoteName( aQuote,sSelectTableName)); aFilter.append(s_sDot); aFilter.append(::dbtools::quoteName( aQuote,aPosIter->second.sRealName)); aFilter.append(s_sParam); - } } break; } } - } // if ( aSeq.getLength() > 1 ) // special handling for join + } executeStatement(aFilter,i_sRowSetFilter,xAnalyzer); } void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OUString& i_sRowSetFilter,Reference<XSingleSelectQueryComposer>& io_xAnalyzer) @@ -380,7 +328,7 @@ void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OU for(;pAnd != pAndEnd;++pAnd) { ::rtl::OUString sValue; - if ( !(pAnd->Value >>= sValue) || !(sValue.equalsAscii("?") || sValue.matchAsciiL(":",1,0)) ) + if ( !(pAnd->Value >>= sValue) || !(sValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("?")) || sValue.matchAsciiL(":",1,0)) ) { // we have a criteria which has to be taken into account for updates m_aFilterColumns.push_back(pAnd->Name); } @@ -390,7 +338,7 @@ void OKeySet::executeStatement(::rtl::OUStringBuffer& io_aFilter,const ::rtl::OU m_xStatement = m_xConnection->prepareStatement(io_xAnalyzer->getQueryWithSubstitution()); ::comphelper::disposeComponent(io_xAnalyzer); } -// ------------------------------------------------------------------------- + Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBookmark" ); @@ -399,7 +347,6 @@ Any SAL_CALL OKeySet::getBookmark() throw(SQLException, RuntimeException) return makeAny(m_aKeyIter->first); } -// ------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToBookmark" ); @@ -407,7 +354,7 @@ sal_Bool SAL_CALL OKeySet::moveToBookmark( const Any& bookmark ) throw(SQLExcept m_aKeyIter = m_aKeyMap.find(::comphelper::getINT32(bookmark)); return m_aKeyIter != m_aKeyMap.end(); } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveRelativeToBookmark" ); @@ -420,7 +367,7 @@ sal_Bool SAL_CALL OKeySet::moveRelativeToBookmark( const Any& bookmark, sal_Int3 return !isBeforeFirst() && !isAfterLast(); } -// ------------------------------------------------------------------------- + sal_Int32 SAL_CALL OKeySet::compareBookmarks( const Any& _first, const Any& _second ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::compareBookmarks" ); @@ -430,19 +377,19 @@ sal_Int32 SAL_CALL OKeySet::compareBookmarks( const Any& _first, const Any& _sec return (nFirst != nSecond) ? CompareBookmark::NOT_EQUAL : CompareBookmark::EQUAL; } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hasOrderedBookmarks" ); return sal_True; } -// ------------------------------------------------------------------------- + sal_Int32 SAL_CALL OKeySet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::hashBookmark" ); return ::comphelper::getINT32(bookmark); } -// ------------------------------------------------------------------------- + // ::com::sun::star::sdbcx::XDeleteRows Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows ,const connectivity::OSQLTable& _xTable) throw(SQLException, RuntimeException) { @@ -450,22 +397,22 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DELETE FROM ")); aSql.append(m_aComposedTableName); - aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "))); // list all cloumns that should be set const ::rtl::OUString aQuote = getIdentifierQuoteString(); - static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); - static ::rtl::OUString aOr = ::rtl::OUString::createFromAscii(" OR "); - static ::rtl::OUString aEqual = ::rtl::OUString::createFromAscii(" = ?"); + static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); + static ::rtl::OUString aOr(RTL_CONSTASCII_USTRINGPARAM(" OR ")); + static ::rtl::OUString aEqual(RTL_CONSTASCII_USTRINGPARAM(" = ?")); // use keys and indexes for excat postioning // first the keys Reference<XNameAccess> xKeyColumns = getKeyColumns(); - ::rtl::OUStringBuffer aCondition = ::rtl::OUString::createFromAscii("( "); + ::rtl::OUStringBuffer aCondition = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("( ")); SelectColumnsMetaData::const_iterator aIter = (*m_pKeyColumnNames).begin(); SelectColumnsMetaData::const_iterator aPosEnd = (*m_pKeyColumnNames).end(); @@ -531,20 +478,20 @@ Sequence< sal_Int32 > SAL_CALL OKeySet::deleteRows( const Sequence< Any >& rows } return aRet; } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::updateRow" ); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("UPDATE "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UPDATE ")); aSql.append(m_aComposedTableName); - aSql.append(::rtl::OUString::createFromAscii(" SET ")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SET "))); // list all cloumns that should be set - static ::rtl::OUString aPara = ::rtl::OUString::createFromAscii(" = ?,"); + static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM(" = ?,")); ::rtl::OUString aQuote = getIdentifierQuoteString(); - static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); ::rtl::OUString sIsNull(RTL_CONSTASCII_USTRINGPARAM(" IS NULL")); ::rtl::OUString sParam(RTL_CONSTASCII_USTRINGPARAM(" = ?")); @@ -573,7 +520,6 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow SelectColumnsMetaData::const_iterator aEnd = m_pColumnNames->end(); for(;aIter != aEnd;++aIter,++i) { - //if(xKeyColumns.is() && xKeyColumns->hasByName(aIter->first)) if ( m_pKeyColumnNames->find(aIter->first) != m_pKeyColumnNames->end() ) { sKeyCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName)); @@ -620,7 +566,7 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow if(sKeyCondition.getLength() || sIndexCondition.getLength()) { - aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "))); if(sKeyCondition.getLength() && sIndexCondition.getLength()) { aSql.append(sKeyCondition.makeStringAndClear()); @@ -640,11 +586,10 @@ void SAL_CALL OKeySet::updateRow(const ORowSetRow& _rInsertRow ,const ORowSetRow ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_CONDITION_FOR_PK ), SQL_GENERAL_ERROR, m_xConnection ); // now create end execute the prepared statement - ::rtl::OUString sEmpty; executeUpdate(_rInsertRow ,_rOrginalRow,aSql.makeStringAndClear(),sEmpty,aIndexColumnPositions); } -// ----------------------------------------------------------------------------- + void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rOrginalRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,const ::std::vector<sal_Int32>& _aIndexColumnPositions) { // now create end execute the prepared statement @@ -710,16 +655,16 @@ void OKeySet::executeUpdate(const ORowSetRow& _rInsertRow ,const ORowSetRow& _rO tryRefetch(_rInsertRow,bRefetch); } } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::insertRow" ); - ::rtl::OUStringBuffer aSql(::rtl::OUString::createFromAscii("INSERT INTO ")); + ::rtl::OUStringBuffer aSql(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INSERT INTO "))); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); aSql.append(m_aComposedTableName); - aSql.append(::rtl::OUString::createFromAscii(" ( ")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ( "))); // set values and column names ::rtl::OUStringBuffer aValues(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VALUES ( "))); static ::rtl::OUString aPara(RTL_CONSTASCII_USTRINGPARAM("?,")); @@ -755,7 +700,7 @@ void SAL_CALL OKeySet::insertRow( const ORowSetRow& _rInsertRow,const connectivi ::rtl::OUString sEmpty; executeInsert(_rInsertRow,aSql.makeStringAndClear(),sEmpty,bRefetch); } -// ------------------------------------------------------------------------- + void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName,bool bRefetch ) { // now create,fill and execute the prepared statement @@ -821,9 +766,9 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString } } } - catch(Exception&) + catch(const Exception&) { - OSL_ENSURE(0,"Could not execute GeneratedKeys() stmt"); + OSL_FAIL("Could not execute GeneratedKeys() stmt"); } } @@ -854,10 +799,10 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString if(sMaxStmt.getLength()) { - sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString::createFromAscii(" ")); - ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT "); + sMaxStmt = sMaxStmt.replaceAt(sMaxStmt.getLength()-1,1,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "))); + ::rtl::OUString sStmt = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")); sStmt += sMaxStmt; - sStmt += ::rtl::OUString::createFromAscii("FROM "); + sStmt += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FROM ")); ::rtl::OUString sCatalog,sSchema,sTable; ::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); @@ -882,7 +827,7 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString } catch(SQLException&) { - OSL_ENSURE(0,"Could not fetch with MAX() "); + OSL_FAIL("Could not fetch with MAX() "); } } } @@ -943,7 +888,7 @@ void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch) OSL_ENSURE(m_xSet.is(),"No resultset form statement!"); bRefetch = m_xSet->next(); } - catch(Exception) + catch(const Exception&) { bRefetch = false; } @@ -953,7 +898,7 @@ void OKeySet::tryRefetch(const ORowSetRow& _rInsertRow,bool bRefetch) m_aKeyIter->second.second.second = new OPrivateRow(_rInsertRow->get()); } } -// ----------------------------------------------------------------------------- + void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sal_Int32 i_nBookmark) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::copyRowValue" ); @@ -993,20 +938,20 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa aIter->setTypeKind(aPosIter->second.nType); } } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivity::OSQLTable& _xTable ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::deleteRow" ); Reference<XPropertySet> xSet(_xTable,UNO_QUERY); fillTableName(xSet); - ::rtl::OUStringBuffer aSql = ::rtl::OUString::createFromAscii("DELETE FROM "); + ::rtl::OUStringBuffer aSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DELETE FROM ")); aSql.append(m_aComposedTableName); - aSql.append(::rtl::OUString::createFromAscii(" WHERE ")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" WHERE "))); // list all cloumns that should be set ::rtl::OUString aQuote = getIdentifierQuoteString(); - static ::rtl::OUString aAnd = ::rtl::OUString::createFromAscii(" AND "); + static ::rtl::OUString aAnd(RTL_CONSTASCII_USTRINGPARAM(" AND ")); // use keys and indexes for excat postioning Reference<XNameAccess> xKeyColumns = getKeyColumns(); @@ -1034,11 +979,11 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit aSql.append(::dbtools::quoteName( aQuote,aIter->second.sRealName)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) { - OSL_ENSURE(0,"can a primary key be null"); - aSql.append(::rtl::OUString::createFromAscii(" IS NULL")); + OSL_FAIL("can a primary key be null"); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"))); } else - aSql.append(::rtl::OUString::createFromAscii(" = ?")); + aSql.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ?"))); aSql.append(aAnd); } else @@ -1051,10 +996,10 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit { sIndexCondition.append(::dbtools::quoteName( aQuote,aIter->second.sRealName)); if((_rDeleteRow->get())[aIter->second.nPosition].isNull()) - sIndexCondition.append(::rtl::OUString::createFromAscii(" IS NULL")); + sIndexCondition.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" IS NULL"))); else { - sIndexCondition.append(::rtl::OUString::createFromAscii(" = ?")); + sIndexCondition.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" = ?"))); aIndexColumnPositions.push_back(aIter->second.nPosition); } sIndexCondition.append(aAnd); @@ -1099,23 +1044,23 @@ void SAL_CALL OKeySet::deleteRow(const ORowSetRow& _rDeleteRow,const connectivit m_bDeleted = sal_True; } } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::cancelRowUpdates( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::cancelRowUpdates" ); m_bInserted = m_bUpdated = m_bDeleted = sal_False; } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::moveToInsertRow( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToInsertRow" ); } -// ------------------------------------------------------------------------- + void SAL_CALL OKeySet::moveToCurrentRow( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::moveToCurrentRow" ); } -// ------------------------------------------------------------------------- + Reference<XNameAccess> OKeySet::getKeyColumns() const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getKeyColumns" ); @@ -1156,7 +1101,7 @@ Reference<XNameAccess> OKeySet::getKeyColumns() const return xKeyColumns; } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::next" ); @@ -1182,19 +1127,19 @@ sal_Bool SAL_CALL OKeySet::next( ) throw(SQLException, RuntimeException) refreshRow(); return !isAfterLast(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::isBeforeFirst( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isBeforeFirst" ); return m_aKeyIter == m_aKeyMap.begin(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::isAfterLast( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isAfterLast" ); return m_bRowCountFinal && m_aKeyIter == m_aKeyMap.end(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::isFirst( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isFirst" ); @@ -1202,7 +1147,7 @@ sal_Bool SAL_CALL OKeySet::isFirst( ) throw(SQLException, RuntimeException) ++aTemp; return m_aKeyIter == aTemp && m_aKeyIter != m_aKeyMap.end(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::isLast( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::isLast" ); @@ -1213,7 +1158,7 @@ sal_Bool SAL_CALL OKeySet::isLast( ) throw(SQLException, RuntimeException) --aTemp; return m_aKeyIter == aTemp; } -// ----------------------------------------------------------------------------- + void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::beforeFirst" ); @@ -1222,7 +1167,7 @@ void SAL_CALL OKeySet::beforeFirst( ) throw(SQLException, RuntimeException) m_xRow = NULL; ::comphelper::disposeComponent(m_xSet); } -// ----------------------------------------------------------------------------- + void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::afterLast" ); @@ -1232,7 +1177,7 @@ void SAL_CALL OKeySet::afterLast( ) throw(SQLException, RuntimeException) m_xRow = NULL; ::comphelper::disposeComponent(m_xSet); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::first" ); @@ -1245,7 +1190,7 @@ sal_Bool SAL_CALL OKeySet::first( ) throw(SQLException, RuntimeException) refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::last( ) throw(SQLException, RuntimeException) { return last_checked(sal_True); @@ -1263,7 +1208,7 @@ sal_Bool OKeySet::last_checked( sal_Bool i_bFetchRow) refreshRow(); return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } -// ----------------------------------------------------------------------------- + sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRow" ); @@ -1272,7 +1217,7 @@ sal_Int32 SAL_CALL OKeySet::getRow( ) throw(SQLException, RuntimeException) return ::std::distance(m_aKeyMap.begin(),m_aKeyIter); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) { return absolute_checked(row,sal_True); @@ -1320,7 +1265,7 @@ sal_Bool OKeySet::absolute_checked( sal_Int32 row,sal_Bool i_bFetchRow ) return m_aKeyIter != m_aKeyMap.end() && m_aKeyIter != m_aKeyMap.begin(); } -// ----------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::relative" ); @@ -1331,7 +1276,7 @@ sal_Bool SAL_CALL OKeySet::relative( sal_Int32 rows ) throw(SQLException, Runtim } return absolute(getRow()+rows); } -// ----------------------------------------------------------------------------- + sal_Bool OKeySet::previous_checked( sal_Bool i_bFetchRow ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::previous" ); @@ -1344,7 +1289,6 @@ sal_Bool OKeySet::previous_checked( sal_Bool i_bFetchRow ) } return m_aKeyIter != m_aKeyMap.begin(); } -// ----------------------------------------------------------------------------- sal_Bool SAL_CALL OKeySet::previous( ) throw(SQLException, RuntimeException) { return previous_checked(sal_True); @@ -1418,7 +1362,7 @@ void SAL_CALL OKeySet::refreshRow() throw(SQLException, RuntimeException) OSL_ENSURE(m_xRow.is(),"No row form statement!"); } } -// ----------------------------------------------------------------------------- + sal_Bool OKeySet::fetchRow() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fetchRow" ); @@ -1452,7 +1396,7 @@ sal_Bool OKeySet::fetchRow() m_bRowCountFinal = sal_True; return bRet; } -// ------------------------------------------------------------------------- + void OKeySet::fillAllRows() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::fillAllRows" ); @@ -1468,152 +1412,152 @@ sal_Bool SAL_CALL OKeySet::wasNull( ) throw(SQLException, RuntimeException) RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::wasNull" ); return m_xRow->wasNull(); } -// ------------------------------------------------------------------------- + ::rtl::OUString SAL_CALL OKeySet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getString" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getString(columnIndex); } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBoolean" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getBoolean(columnIndex); } -// ------------------------------------------------------------------------- + sal_Int8 SAL_CALL OKeySet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getByte" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getByte(columnIndex); } -// ------------------------------------------------------------------------- + sal_Int16 SAL_CALL OKeySet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getShort" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getShort(columnIndex); } -// ------------------------------------------------------------------------- + sal_Int32 SAL_CALL OKeySet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getInt" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getInt(columnIndex); } -// ------------------------------------------------------------------------- + sal_Int64 SAL_CALL OKeySet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getLong" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getLong(columnIndex); } -// ------------------------------------------------------------------------- + float SAL_CALL OKeySet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getFloat" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getFloat(columnIndex); } -// ------------------------------------------------------------------------- + double SAL_CALL OKeySet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDouble" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getDouble(columnIndex); } -// ------------------------------------------------------------------------- + Sequence< sal_Int8 > SAL_CALL OKeySet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBytes" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getBytes(columnIndex); } -// ------------------------------------------------------------------------- + ::com::sun::star::util::Date SAL_CALL OKeySet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getDate" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getDate(columnIndex); } -// ------------------------------------------------------------------------- + ::com::sun::star::util::Time SAL_CALL OKeySet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTime" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getTime(columnIndex); } -// ------------------------------------------------------------------------- + ::com::sun::star::util::DateTime SAL_CALL OKeySet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getTimestamp" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getTimestamp(columnIndex); } -// ------------------------------------------------------------------------- + Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBinaryStream" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getBinaryStream(columnIndex); } -// ------------------------------------------------------------------------- + Reference< ::com::sun::star::io::XInputStream > SAL_CALL OKeySet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getCharacterStream" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getCharacterStream(columnIndex); } -// ------------------------------------------------------------------------- + Any SAL_CALL OKeySet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getObject" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getObject(columnIndex,typeMap); } -// ------------------------------------------------------------------------- + Reference< XRef > SAL_CALL OKeySet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getRef" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getRef(columnIndex); } -// ------------------------------------------------------------------------- + Reference< XBlob > SAL_CALL OKeySet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getBlob" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getBlob(columnIndex); } -// ------------------------------------------------------------------------- + Reference< XClob > SAL_CALL OKeySet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getClob" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getClob(columnIndex); } -// ------------------------------------------------------------------------- + Reference< XArray > SAL_CALL OKeySet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::getArray" ); OSL_ENSURE(m_xRow.is(),"m_xRow is null!"); return m_xRow->getArray(columnIndex); } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::rowUpdated( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowUpdated" ); return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 2; } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::rowInserted( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowInserted" ); return m_aKeyIter != m_aKeyMap.begin() && m_aKeyIter != m_aKeyMap.end() && m_aKeyIter->second.second.first == 1; } -// ------------------------------------------------------------------------- + sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OKeySet::rowDeleted" ); @@ -1621,7 +1565,7 @@ sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) m_bDeleted = sal_False; return bDeleted; } -// ----------------------------------------------------------------------------- + ::rtl::OUString OKeySet::getComposedTableName(const ::rtl::OUString& _sCatalog, const ::rtl::OUString& _sSchema, const ::rtl::OUString& _sTable) @@ -1654,7 +1598,7 @@ sal_Bool SAL_CALL OKeySet::rowDeleted( ) throw(SQLException, RuntimeException) return aComposedName; } -// ----------------------------------------------------------------------------- + namespace dbaccess { @@ -1721,7 +1665,7 @@ void getColumnPositions(const Reference<XNameAccess>& _rxQueryColumns, } } } -// ----------------------------------------------------------------------------- + void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData) { ORowSetValue& aValue((_rInsertRow->get())[i_aMetaData.nPosition]); @@ -1742,5 +1686,4 @@ void OKeySet::impl_convertValue_throw(const ORowSetRow& _rInsertRow,const Select break; } } -// ----------------------------------------------------------------------------- - +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |