summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-14 12:25:43 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-14 17:24:58 +0100
commitb174e1b733892778c9301d3b1f8d92573d317de5 (patch)
treecc5b3956c929f4e7478aea50661331d316411c84 /connectivity
parent5b0c06c291157a08de568735935f5f9f6c80ee83 (diff)
Implement column-name altering. (firebird-sdbc)
Change-Id: I93bdbd37976fe467459b7fb39c26f6637ea7e84e
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Table.cxx36
-rw-r--r--connectivity/source/drivers/firebird/Table.hxx12
2 files changed, 48 insertions, 0 deletions
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index 1cd98136ba6e..80f107cb6cce 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -21,7 +21,10 @@ using namespace ::osl;
using namespace ::rtl;
using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
Table::Table(Tables* pTables,
Mutex& rMutex,
@@ -66,4 +69,37 @@ OCollection* Table::createIndexes(const TStringVector& rNames)
rNames);
}
+//----- XAlterTable -----------------------------------------------------------
+void SAL_CALL Table::alterColumnByName(const OUString& rColName,
+ const uno::Reference< XPropertySet >& rDescriptor)
+ throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ MutexGuard aGuard(m_rMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ uno::Reference< XPropertySet > xColumn(m_pColumns->getByName(rColName), UNO_QUERY);
+
+ // sdbcx::Descriptor
+ bool bNameChanged = xColumn->getPropertyValue("Name") != rDescriptor->getPropertyValue("Name");
+ // sdbcx::ColumnDescriptor
+// bool bTypeChanged = xColumn->getPropertyValue("Type") != rDescriptor->getPropertyValue("Type");
+// bool bTypeNameChanged = xColumn->getPropertyValue("TypeName") != rDescriptor->getPropertyValue("TypeName");
+// bool bPrecisionChanged = xColumn->getPropertyValue("Precision") != rDescriptor->getPropertyValue("Precision");
+// bool bScaleChanged = xColumn->getPropertyValue("Scale") != rDescriptor->getPropertyValue("Scale");
+// bool bIsNullableChanged = xColumn->getPropertyValue("IsNullable") != rDescriptor->getPropertyValue("IsNullable");
+// bool bIsAutoIncrementChanged = xColumn->getPropertyValue("IsAutoIncrement") != rDescriptor->getPropertyValue("IsAutoIncrement");
+ // TODO: remainder
+
+ if (bNameChanged)
+ {
+ OUString sNewTableName;
+ rDescriptor->getPropertyValue("Name") >>= sNewTableName;
+ OUString sSql("ALTER TABLE \"" + getName() + "\" ALTER COLUMN \""
+ + rColName + "\" TO \"" + sNewTableName + "\"");
+
+ getConnection()->createStatement()->execute(sSql);
+ }
+
+ // TODO: implement me
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx
index 0ea469503f89..cfeaea178005 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -40,6 +40,18 @@ namespace connectivity
virtual ::connectivity::sdbcx::OCollection* createIndexes(
const ::connectivity::TStringVector& rNames);
+ // XAlterTable
+ /**
+ * See ::com::sun::star::sdbcx::ColumnDescriptor for details of
+ * rDescriptor.
+ */
+ virtual void SAL_CALL alterColumnByName(
+ const ::rtl::OUString& rColName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rDescriptor)
+ throw(::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+
};
} // namespace firebird