/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// set type what to do if( IsOptionDefData() )
m_pParent->setOperation( CopyTableOperation::CopyDefinitionAndData ); elseif( IsOptionDef() )
m_pParent->setOperation( CopyTableOperation::CopyDefinitionOnly ); elseif( IsOptionView() )
m_pParent->setOperation( CopyTableOperation::CreateAsView );
}
// first check if the table already exists in the database if( m_pParent->getOperation() != CopyTableOperation::AppendData )
{
m_pParent->clearDestColumns();
DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE );
SQLExceptionInfo aErrorInfo; if ( !aNameCheck.isNameValid( m_xEdTableName->get_text(), aErrorInfo ) )
{
aErrorInfo.append( SQLExceptionInfo::TYPE::SQLContext, DBA_RES( STR_SUGGEST_APPEND_TABLE_DATA ) );
m_pParent->showError(aErrorInfo.get());
returnfalse;
}
// have to check the length of the table name
Reference< XDatabaseMetaData > xMeta = m_pParent->m_xDestConnection->getMetaData();
OUString sCatalog;
OUString sSchema;
OUString sTable;
::dbtools::qualifiedNameComponents( xMeta,
m_xEdTableName->get_text(),
sCatalog,
sSchema,
sTable,
::dbtools::EComposeRule::InDataManipulation);
sal_Int32 nMaxLength = xMeta->getMaxTableNameLength(); if ( nMaxLength && sTable.getLength() > nMaxLength )
{
m_pParent->showError(DBA_RES(STR_INVALID_TABLE_NAME_LENGTH)); returnfalse;
}
// now we have to check if the name of the primary key already exists if ( m_pParent->m_bCreatePrimaryKeyColumn
&& m_pParent->m_aKeyName != m_pParent->createUniqueName(m_pParent->m_aKeyName) )
{
m_pParent->showError(DBA_RES(STR_WIZ_NAME_ALREADY_DEFINED) + " " + m_pParent->m_aKeyName); returnfalse;
}
}
if (m_xEdTableName->get_value_changed_from_saved())
{ // table exists and name has changed if ( m_pParent->getOperation() == CopyTableOperation::AppendData )
{ if(!checkAppendData()) returnfalse;
} elseif ( m_nOldOperation == CopyTableOperation::AppendData )
{
m_xEdTableName->save_value(); return LeavePage();
}
} else
{ // table exist and is not new or doesn't exist and so on if ( CopyTableOperation::AppendData == m_pParent->getOperation() )
{ if( !checkAppendData() ) returnfalse;
}
}
m_pParent->m_sName = m_xEdTableName->get_text();
m_xEdTableName->save_value();
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.