19#include <com/sun/star/sdbc/XRow.hpp>
20#include <com/sun/star/sdbc/ColumnValue.hpp>
21#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
27using namespace ::
cppu;
40void Tables::impl_refresh()
42 static_cast<Catalog&
>(
m_rParent).refreshTables();
45ObjectType Tables::createObject(
const OUString& rName)
48 uno::Reference< XResultSet > xTables = m_xMetaData->getTables(
Any(),
51 uno::Sequence< OUString >());
56 uno::Reference< XRow > xRow(xTables,UNO_QUERY_THROW);
63 m_xMetaData->getConnection(),
76 Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
80 bool bIsAutoIncrement =
false;
83 const OUString sQuoteString = xMetaData->getIdentifierQuoteString();
87 OUString sAutoIncrementValue;
88 Reference<XPropertySetInfo> xPropInfo = xColProp->getPropertySetInfo();
98 if ( xPropInfo.is() && xPropInfo->hasPropertyByName(rPropMap.
getNameByIndex(
104 if(aType == DataType::BINARY || aType == DataType::VARBINARY)
106 aSql.append(
" CHARACTER SET OCTETS");
110 if ( bIsAutoIncrement && !sAutoIncrementValue.isEmpty())
112 aSql.append(
" " + sAutoIncrementValue);
116 aSql.append(
" NOT NULL");
118 return aSql.makeStringAndClear();
121uno::Reference< XPropertySet > Tables::createDescriptor()
126 return new Table(
this, m_rMutex, m_xMetaData->getConnection());
130ObjectType Tables::appendObject(
const OUString& rName,
131 const uno::Reference< XPropertySet >& rDescriptor)
135 OUStringBuffer aSqlBuffer(
"CREATE TABLE ");
137 const Reference< XConnection>& xConnection = m_xMetaData->getConnection();
149 aSqlBuffer.append(sComposedName
153 Reference<XColumnsSupplier> xColumnSup(rDescriptor,UNO_QUERY);
154 Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
156 if(!xColumns.is() || !xColumns->getCount())
159 Reference< XPropertySet > xColProp;
161 sal_Int32
nCount = xColumns->getCount();
164 if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() )
170 OUString sSql = aSqlBuffer.makeStringAndClear();
173 if ( !sKeyStmt.isEmpty() )
177 if ( sSql.endsWith(
",") )
178 sSql = sSql.replaceAt(sSql.getLength()-1, 1, u
")");
183 m_xMetaData->getConnection()->createStatement()->execute(sSql);
185 return createObject(rName);
189void Tables::dropObject(sal_Int32 nPosition,
const OUString& sName)
191 uno::Reference< XPropertySet > xTable(getObject(nPosition));
193 if (ODescriptor::isNew(xTable))
197 xTable->getPropertyValue(
"Type") >>=
sType;
199 const OUString sQuoteString = m_xMetaData->getIdentifierQuoteString();
201 m_xMetaData->getConnection()->createStatement()->execute(
206 Views* pViews =
static_cast<Views*
>(
static_cast<Catalog&
>(
m_rParent).getPrivateViews());
207 if ( pViews && pViews->hasByName(sName) )
208 pViews->dropByNameImpl(sName);
217 css::container::ContainerEvent
aEvent(
static_cast<XContainer*
>(
this),
218 css::uno::Any(_rsNewTable), css::uno::Any(),
222 aListenerLoop.
next()->elementInserted(
aEvent);
OptionalString sComposedName
bool hasMoreElements() const
css::uno::Reference< ListenerT > const & next()
void appendNew(const OUString &_rsNewTable)
void insertElement(const OUString &_sElementName, const ObjectType &_xElement)
insert a new element into the collection
::comphelper::OInterfaceContainerHelper3< css::container::XContainerListener > m_aContainerListeners
css::uno::Reference< css::beans::XPropertySet > ObjectType
#define PROPERTY_ID_AUTOINCREMENTCREATION
#define PROPERTY_ID_CATALOGNAME
#define PROPERTY_ID_ISNULLABLE
#define PROPERTY_ID_SCHEMANAME
#define PROPERTY_ID_ISAUTOINCREMENT