summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/relationdesign/RTableConnectionData.cxx')
-rw-r--r--dbaccess/source/ui/relationdesign/RTableConnectionData.cxx41
1 files changed, 14 insertions, 27 deletions
diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
index 6e81b8b15088..f052003c2c58 100644
--- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
+++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx
@@ -30,42 +30,22 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef DBAUI_RTABLECONNECTIONDATA_HXX
#include "RTableConnectionData.hxx"
-#endif
-#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
-#endif
-#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_
#include <com/sun/star/sdbc/KeyRule.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_
#include <com/sun/star/sdbcx/KeyType.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_
#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
#include <com/sun/star/sdbcx/XAppend.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_
#include <com/sun/star/sdbcx/XDrop.hpp>
-#endif
-#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
#include <com/sun/star/container/XIndexAccess.hpp>
-#endif
-#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
#include "dbustrings.hrc"
-#endif
-#ifndef DBAUI_TOOLS_HXX
+#include "dbu_rel.hrc"
#include "UITools.hxx"
-#endif
+#include "moduledbu.hxx"
+#include <connectivity/dbexception.hxx>
+
using namespace dbaui;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
@@ -382,6 +362,7 @@ BOOL ORelationTableConnectionData::Update()
// get the name of foreign key // search for columns
m_aConnName = ::rtl::OUString();
xKey = NULL;
+ bool bDropRelation = false;
for(sal_Int32 i=0;i<xKeys->getCount();++i)
{
xKeys->getByIndex(i) >>= xKey;
@@ -426,6 +407,7 @@ BOOL ORelationTableConnectionData::Update()
{
xKey->getPropertyValue(PROPERTY_NAME) >>= sName;
m_aConnName = sName;
+ bDropRelation = aNames.getLength() == 0; // the key contains no column, so it isn't valid and we have to drop it
//here we already know our column structure so we don't have to recreate the table connection data
xColSup.clear();
break;
@@ -437,15 +419,20 @@ BOOL ORelationTableConnectionData::Update()
}
}
xKey = NULL;
+ } // for(sal_Int32 i=0;i<xKeys->getCount();++i)
+ if ( bDropRelation )
+ {
+ DropRelation();
+ String sError(ModuleRes(STR_QUERY_REL_COULD_NOT_CREATE));
+ ::dbtools::throwGenericSQLException(sError,NULL);
}
// OSL_ENSURE(xKey.is(),"No key found have insertion!");
+ // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated
if ( xColSup.is() )
{
- // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated
OConnectionLineDataVec().swap(m_vConnLineData);
-
Reference<XNameAccess> xColumns = xColSup->getColumns();
Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
const ::rtl::OUString* pIter = aNames.getConstArray();
@@ -470,7 +457,7 @@ BOOL ORelationTableConnectionData::Update()
m_vConnLineData.push_back(pNewData);
}
}
- }
+ } // if ( xColSup.is() )
// NOTE : the caller is resposible for updating any other objects referencing the old LineDatas (for instance a ConnLine)
////////////////////////////////////////////////////////////