Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include "Keys.hxx"
11 : #include "Table.hxx"
12 :
13 : #include <connectivity/dbtools.hxx>
14 :
15 : using namespace ::connectivity;
16 : using namespace ::connectivity::firebird;
17 :
18 : using namespace ::dbtools;
19 : using namespace ::osl;
20 :
21 : using namespace ::com::sun::star;
22 : using namespace ::com::sun::star::beans;
23 : using namespace ::com::sun::star::sdbc;
24 : using namespace ::com::sun::star::uno;
25 :
26 2 : Keys::Keys(Table* pTable, Mutex& rMutex, const TStringVector& rNames):
27 : OKeysHelper(pTable,
28 : rMutex,
29 : rNames),
30 2 : m_pTable(pTable)
31 : {
32 2 : }
33 :
34 : //----- XDrop ----------------------------------------------------------------
35 0 : void Keys::dropObject(sal_Int32 nPosition, const OUString& sName)
36 : {
37 0 : Reference< XConnection> xConnection = m_pTable->getConnection();
38 :
39 0 : if (!m_pTable->isNew())
40 : {
41 0 : uno::Reference<XPropertySet> xKey(getObject(nPosition), UNO_QUERY);
42 :
43 0 : if (xKey.is())
44 : {
45 0 : const OUString sQuote = m_pTable->getConnection()->getMetaData()
46 0 : ->getIdentifierQuoteString();
47 :
48 0 : OUString sSql("ALTER TABLE " + quoteName(sQuote, m_pTable->getName())
49 0 : + " DROP CONSTRAINT " + quoteName(sQuote, sName));
50 :
51 0 : m_pTable->getConnection()->createStatement()->execute(sSql);
52 0 : }
53 0 : }
54 0 : }
55 :
56 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|