using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Any; using ::com::sun::star::sdbc::SQLException; using ::com::sun::star::sdbc::XConnection; using ::com::sun::star::lang::WrappedTargetException; using ::com::sun::star::sdbc::XResultSet; using ::com::sun::star::sdbc::XStatement; using ::com::sun::star::lang::DisposedException; using ::com::sun::star::sdbc::XRow;
void SAL_CALL HView::alterCommand( const OUString& _rNewCommand )
{ // not really atomic ... as long as we do not have something like // ALTER VIEW <name> TO <command> // in HSQL, we need to do it this way ... // // I can imagine scenarios where this fails, e.g. when dropping the view // succeeds, re-creating it fails, some other thread alters a table which // the view was based on, and then we try to restore the view with the // original command, which then fails, too. // // However, there's not much chance to prevent this kind of errors without // backend support.
// create a statement which can be used to re-create the original view, in case // dropping it succeeds, but creating it with a new statement fails
OUString sRestoreCommand = "CREATE VIEW " +
sQualifiedName + " AS " +
impl_getCommand_throwSQLException();
// create a new one with the same name
aCommand = "CREATE VIEW " + sQualifiedName + " AS " + _rNewCommand;
xStatement->execute( aCommand );
} catch( const SQLException& )
{ if ( bDropSucceeded ) // drop succeeded, but creation failed -> re-create the view with the original // statement
xStatement->execute( sRestoreCommand ); throw;
} catch( const RuntimeException& )
{ if ( bDropSucceeded )
xStatement->execute( sRestoreCommand ); throw;
} catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION("connectivity.hsqldb"); if ( bDropSucceeded )
xStatement->execute( sRestoreCommand );
}
}
void SAL_CALL HView::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
{ if ( _nHandle == PROPERTY_ID_COMMAND )
{ // retrieve the very current command, don't rely on the base classes cached value // (which we initialized empty, anyway)
_rValue <<= impl_getCommand_wrapSQLException(); return;
}
OUString HView::impl_getCommand() const
{
OUStringBuffer aCommand( "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.SYSTEM_VIEWS " );
HTools::appendTableFilterCrit( aCommand, m_CatalogName, m_SchemaName, m_Name, false );
::utl::SharedUNOComponent< XStatement > xStatement; xStatement.set( m_xConnection->createStatement(), UNO_QUERY_THROW );
Reference< XResultSet > xResult( xStatement->executeQuery( aCommand.makeStringAndClear() ), css::uno::UNO_SET_THROW ); if ( !xResult->next() )
{ // hmm. There is no view the name as we know it. Can only mean some other instance // dropped this view meanwhile... throw DisposedException();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.