diff options
Diffstat (limited to 'dbaccess/source/core/api/RowSet.cxx')
-rw-r--r-- | dbaccess/source/core/api/RowSet.cxx | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 18d8398c8233..0de2b0511946 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -977,19 +977,26 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) m_pCache->updateRow(m_aCurrentRow.operator ->()); m_aBookmark = m_pCache->getBookmark(); m_aCurrentRow = m_pCache->m_aMatrixIter; - m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); + if ( m_pCache->m_aMatrixIter != m_pCache->getEnd() ) + { + m_aOldRow->setRow(new ORowSetValueVector(m_aCurrentRow->getBody())); - // notification order - // - column values - ORowSetBase::firePropertyChange(aOldValues); + // notification order + // - column values + ORowSetBase::firePropertyChange(aOldValues); - // - rowChanged - notifyAllListenersRowChanged(aGuard,aEvt); + // - rowChanged + notifyAllListenersRowChanged(aGuard,aEvt); - // - IsModified - if(!m_bModified) - fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); - OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); + // - IsModified + if(!m_bModified) + fireProperty(PROPERTY_ID_ISMODIFIED,sal_False,sal_True); + OSL_ENSURE( !m_bModified, "ORowSet::updateRow: just updated, but _still_ modified?" ); + } + else // the update went rong + { + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_UPDATE_FAILED ), SQL_INVALID_CURSOR_POSITION, *this ); + } } } // ------------------------------------------------------------------------- @@ -1001,20 +1008,15 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) checkCache(); if ( m_bBeforeFirst || m_bAfterLast ) - throwSQLException( "Cannot delete the before-first or after-last row.", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_BEFORE_AFTER ), SQL_INVALID_CURSOR_POSITION, *this ); if ( m_bNew ) - throwSQLException( "Cannot delete the insert-row.", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_INSERT_ROW ), SQL_INVALID_CURSOR_POSITION, *this ); if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY ) - throwSQLException( "Result set is read only.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE ) - throwSQLException( "DELETE privilege not available.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_DELETE_PRIVILEGE ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( rowDeleted() ) - throwSQLException( "Current row already deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); // this call position the cache indirect Any aBookmarkToDelete( m_aBookmark ); @@ -1178,8 +1180,7 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) ::osl::ResettableMutexGuard aGuard( *m_pMutex ); checkPositioningAllowed(); if ( ( m_pCache->m_nPrivileges & Privilege::INSERT ) != Privilege::INSERT ) - throwSQLException( "No insert privileges", SQL_GENERAL_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_INSERT_PRIVILEGE ), SQL_GENERAL_ERROR, *this ); if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1245,8 +1246,7 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException // m_bModified should be true. Also, as soon as somebody calls moveToInsertRow, // our current row should not be deleted anymore. So, we should not have survived the above // check "if ( !m_pCache->m_bNew && !m_bModified )" - throwSQLException( "The current row is deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); if ( notifyAllListenersCursorBeforeMove( aGuard ) ) { @@ -1610,12 +1610,7 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() m_xStatement = m_xActiveConnection->prepareStatement( sCommandToExecute ); if ( !m_xStatement.is() ) { - SQLException aError; - aError.Context = *this; - aError.SQLState = getStandardSQLState( SQL_GENERAL_ERROR ); - aError.Message = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Internal error: no statement object provided by the database driver." ) ); - // TODO: resource - throw aError; + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INTERNAL_ERROR ), SQL_GENERAL_ERROR, *this ); } Reference< XPropertySet > xStatementProps( m_xStatement, UNO_QUERY_THROW ); @@ -1885,15 +1880,17 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi for(sal_Int32 i=1; i <= nCount ;++i) { ::rtl::OUString sName = xMeta->getColumnName(i); + ::rtl::OUString sColumnLabel = xMeta->getColumnLabel(i); // retrieve the column number |i| Reference<XPropertySet> xColumn; { sal_Bool bReFetchName = sal_False; - if (m_xColumns->hasByName(sName)) + if (m_xColumns->hasByName(sColumnLabel)) + m_xColumns->getByName(sColumnLabel) >>= xColumn; + if (!xColumn.is() && m_xColumns->hasByName(sName)) m_xColumns->getByName(sName) >>= xColumn; - if (!xColumn.is() && m_xColumns->hasByName(xMeta->getColumnLabel(i))) - m_xColumns->getByName(xMeta->getColumnLabel(i)) >>= xColumn; + // check if column already in the list we need another if ( aAllColumns.find( xColumn ) != aAllColumns.end() ) { @@ -1934,16 +1931,15 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi aDescription, m_aCurrentRow); aColumns->get().push_back(pColumn); - if(!sName.getLength()) + if(!sColumnLabel.getLength()) { if(xColumn.is()) - xColumn->getPropertyValue(PROPERTY_NAME) >>= sName; + xColumn->getPropertyValue(PROPERTY_NAME) >>= sColumnLabel; else - sName = ::rtl::OUString::createFromAscii("Expression1"); - // TODO: resource + sColumnLabel = DBACORE_RESSTRING( RID_STR_EXPRESSION1 ); } - pColumn->setName(sName); - aNames.push_back(sName); + pColumn->setName(sColumnLabel); + aNames.push_back(sColumnLabel); m_aDataColumns.push_back(pColumn); if ( xColumn.is() ) @@ -2354,8 +2350,7 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() m_aActiveCommand = sCommand; if ( !m_aActiveCommand.getLength() ) - throwSQLException( "No SQL command was provided.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_NO_SQL_COMMAND ), SQL_FUNCTION_SEQUENCE_ERROR, *this ); return bDoEscapeProcessing; } @@ -2657,21 +2652,17 @@ void ORowSet::checkUpdateIterator() void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) { checkCache(); - if ( columnIndex <= 0 ) - throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); - // TODO: resource + if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_RESULT_IS_READONLY ), SQL_GENERAL_ERROR, *this ); + if ( rowDeleted() ) - throwSQLException( "Current row is deleted", SQL_INVALID_CURSOR_POSITION, *this ); - // TODO: resource + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_ROW_ALREADY_DELETED ), SQL_INVALID_CURSOR_POSITION, *this ); + if ( m_aCurrentRow.isNull() ) - throwSQLException( "Invalid cursor state", SQL_INVALID_CURSOR_STATE, *this ); + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_CURSOR_STATE ), SQL_INVALID_CURSOR_STATE, *this ); - if ( sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) - throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); - // TODO: resource - if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) - throwSQLException( "Result set is not writeable", SQL_GENERAL_ERROR, *this ); - // TODO: resource + if ( columnIndex <= 0 || sal_Int32((*m_aCurrentRow)->get().size()) <= columnIndex ) + ::dbtools::throwSQLException( DBACORE_RESSTRING( RID_STR_INVALID_INDEX ), SQL_INVALID_DESCRIPTOR_INDEX, *this ); } // ----------------------------------------------------------------------------- void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) |