1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: table.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBA_CORE_TABLE_HXX_
37 #ifndef _DBACORE_DEFINITIONCOLUMN_HXX_
38 #include <definitioncolumn.hxx>
40 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
41 #include "dbastrings.hrc"
43 #ifndef _DBA_CORE_RESOURCE_HXX_
44 #include "core_resource.hxx"
46 #ifndef _DBA_CORE_RESOURCE_HRC_
47 #include "core_resource.hrc"
49 #ifndef _TOOLS_DEBUG_HXX
50 #include <tools/debug.hxx>
53 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
54 #include <cppuhelper/typeprovider.hxx>
56 #ifndef _COMPHELPER_ENUMHELPER_HXX_
57 #include <comphelper/enumhelper.hxx>
59 #ifndef _COMPHELPER_CONTAINER_HXX_
60 #include <comphelper/container.hxx>
62 #ifndef _COMPHELPER_SEQUENCE_HXX_
63 #include <comphelper/sequence.hxx>
65 #ifndef _COMPHELPER_TYPES_HXX_
66 #include <comphelper/types.hxx>
68 #ifndef _COM_SUN_STAR_UTIL_XREFRESHLISTENER_HPP_
69 #include <com/sun/star/util/XRefreshListener.hpp>
71 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
72 #include <com/sun/star/sdbc/XConnection.hpp>
74 #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
75 #include <com/sun/star/sdbc/XRow.hpp>
77 #ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
78 #include <com/sun/star/sdbcx/Privilege.hpp>
80 #include <connectivity/TKeys.hxx>
81 #ifndef DBACCESS_INDEXES_HXX_
82 #include "CIndexes.hxx"
84 #ifndef _CONNECTIVITY_DBTOOLS_HXX_
85 #include <connectivity/dbtools.hxx>
87 #ifndef _DBHELPER_DBEXCEPTION_HXX_
88 #include <connectivity/dbexception.hxx>
90 #ifndef _COMPHELPER_EXTRACT_HXX_
91 #include <comphelper/extract.hxx>
93 #ifndef DBACORE_SDBCORETOOLS_HXX
94 #include "sdbcoretools.hxx"
96 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_
97 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
99 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
100 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
102 #ifndef DBA_CONTAINERMEDIATOR_HXX
103 #include "ContainerMediator.hxx"
105 #include <rtl/logfile.hxx>
107 using namespace dbaccess
;
108 using namespace connectivity
;
109 using namespace ::com::sun::star::uno
;
110 using namespace ::com::sun::star::util
;
111 using namespace ::com::sun::star::lang
;
112 using namespace ::com::sun::star::beans
;
113 using namespace ::com::sun::star::sdbc
;
114 using namespace ::com::sun::star::sdbcx
;
115 using namespace ::com::sun::star::container
;
116 using namespace ::osl
;
117 using namespace ::comphelper
;
118 using namespace ::cppu
;
120 typedef ::std::map
<sal_Int32
, OTableColumn
*, std::less
<sal_Int32
> > OColMap
;
122 //==========================================================================
124 //==========================================================================
126 //--------------------------------------------------------------------------
127 ODBTable::ODBTable(connectivity::sdbcx::OCollection
* _pTables
128 ,const Reference
< XConnection
>& _rxConn
129 ,const ::rtl::OUString
& _rCatalog
130 ,const ::rtl::OUString
& _rSchema
131 ,const ::rtl::OUString
& _rName
132 ,const ::rtl::OUString
& _rType
133 ,const ::rtl::OUString
& _rDesc
134 ,const Reference
< XNameAccess
>& _xColumnDefinitions
) throw(SQLException
)
135 :OTable_Base(_pTables
,_rxConn
,_rxConn
->getMetaData().is() && _rxConn
->getMetaData()->supportsMixedCaseQuotedIdentifiers(), _rName
, _rType
, _rDesc
, _rSchema
, _rCatalog
)
136 ,m_xColumnDefinitions(_xColumnDefinitions
)
139 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
140 DBG_CTOR(ODBTable
, NULL
);
141 DBG_ASSERT(getMetaData().is(), "ODBTable::ODBTable : invalid conn !");
142 DBG_ASSERT(_rName
.getLength(), "ODBTable::ODBTable : name !");
143 // TODO : think about collecting the privileges here, as we can't ensure that in getFastPropertyValue, where
144 // we do this at the moment, the statement needed can be supplied by the connection (for example the SQL-Server
145 // ODBC driver does not allow more than one statement per connection, and in getFastPropertyValue it's more
146 // likely that it's already used up than it's here.)
148 // -----------------------------------------------------------------------------
149 ODBTable::ODBTable(connectivity::sdbcx::OCollection
* _pTables
150 ,const Reference
< XConnection
>& _rxConn
)
152 :OTable_Base(_pTables
,_rxConn
, _rxConn
->getMetaData().is() && _rxConn
->getMetaData()->supportsMixedCaseQuotedIdentifiers())
155 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::ODBTable" );
157 // -------------------------------------------------------------------------
158 ODBTable::~ODBTable()
160 DBG_DTOR(ODBTable
, NULL
);
162 // -----------------------------------------------------------------------------
163 IMPLEMENT_FORWARD_REFCOUNT(ODBTable
,OTable_Base
)
165 //--------------------------------------------------------------------------
166 OColumn
* ODBTable::createColumn(const ::rtl::OUString
& _rName
) const
168 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumn" );
169 OColumn
* pReturn
= NULL
;
171 Reference
<XPropertySet
> xProp
;
172 if ( m_xDriverColumns
.is() && m_xDriverColumns
->hasByName(_rName
) )
174 xProp
.set(m_xDriverColumns
->getByName(_rName
),UNO_QUERY
);
178 OColumns
* pColumns
= static_cast<OColumns
*>(m_pColumns
);
179 xProp
.set(pColumns
->createBaseObject(_rName
),UNO_QUERY
);
182 Reference
<XPropertySet
> xColumnDefintion
;
183 if ( m_xColumnDefinitions
.is() && m_xColumnDefinitions
->hasByName(_rName
) )
184 xColumnDefintion
.set(m_xColumnDefinitions
->getByName(_rName
),UNO_QUERY
);
185 pReturn
= new OTableColumnWrapper(xProp
,xColumnDefintion
);
189 // -----------------------------------------------------------------------------
190 void ODBTable::columnAppended( const Reference
< XPropertySet
>& /*_rxSourceDescriptor*/ )
192 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnAppended" );
195 // -----------------------------------------------------------------------------
196 void ODBTable::columnDropped(const ::rtl::OUString
& _sName
)
198 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::columnDropped" );
199 Reference
<XDrop
> xDrop(m_xColumnDefinitions
,UNO_QUERY
);
200 if ( xDrop
.is() && m_xColumnDefinitions
->hasByName(_sName
) )
202 xDrop
->dropByName(_sName
);
205 //--------------------------------------------------------------------------
206 Sequence
< sal_Int8
> ODBTable::getImplementationId() throw (RuntimeException
)
208 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getImplementationId" );
209 static OImplementationId
* pId
= 0;
212 MutexGuard
aGuard( Mutex::getGlobalMutex() );
215 static OImplementationId aId
;
219 return pId
->getImplementationId();
223 //------------------------------------------------------------------------------
224 void SAL_CALL
ODBTable::disposing()
226 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::disposing" );
227 OPropertySetHelper::disposing();
228 OTable_Base::disposing();
229 m_xColumnDefinitions
= NULL
;
230 m_xDriverColumns
= NULL
;
231 m_pColumnMediator
= NULL
;
234 //------------------------------------------------------------------------------
235 void ODBTable::getFastPropertyValue(Any
& _rValue
, sal_Int32 _nHandle
) const
237 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getFastPropertyValue" );
238 if ((PROPERTY_ID_PRIVILEGES
== _nHandle
) && (-1 == m_nPrivileges
))
239 { // somebody is asking for the privileges an we do not know them, yet
240 const_cast<ODBTable
*>(this)->m_nPrivileges
= ::dbtools::getTablePrivileges(getMetaData(),m_CatalogName
,m_SchemaName
, m_Name
);
243 OTable_Base::getFastPropertyValue(_rValue
, _nHandle
);
245 // -------------------------------------------------------------------------
246 void ODBTable::construct()
248 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::construct" );
249 ::osl::MutexGuard
aGuard(m_aMutex
);
251 // we don't collect the privileges here, this is potentially expensive. Instead we determine them on request.
252 // (see getFastPropertyValue)
255 OTable_Base::construct();
257 registerProperty(PROPERTY_FILTER
, PROPERTY_ID_FILTER
, PropertyAttribute::BOUND
,
258 &m_sFilter
, ::getCppuType(&m_sFilter
));
260 registerProperty(PROPERTY_ORDER
, PROPERTY_ID_ORDER
, PropertyAttribute::BOUND
,
261 &m_sOrder
, ::getCppuType(&m_sOrder
));
263 registerProperty(PROPERTY_APPLYFILTER
, PROPERTY_ID_APPLYFILTER
, PropertyAttribute::BOUND
,
264 &m_bApplyFilter
, ::getBooleanCppuType());
266 registerProperty(PROPERTY_FONT
, PROPERTY_ID_FONT
, PropertyAttribute::BOUND
,
267 &m_aFont
, ::getCppuType(&m_aFont
));
269 registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT
, PROPERTY_ID_ROW_HEIGHT
, PropertyAttribute::BOUND
| PropertyAttribute::MAYBEVOID
,
270 &m_aRowHeight
, ::getCppuType(static_cast<sal_Int32
*>(NULL
)));
272 registerMayBeVoidProperty(PROPERTY_TEXTCOLOR
, PROPERTY_ID_TEXTCOLOR
, PropertyAttribute::BOUND
| PropertyAttribute::MAYBEVOID
,
273 &m_aTextColor
, ::getCppuType(static_cast<sal_Int32
*>(NULL
)));
275 registerProperty(PROPERTY_PRIVILEGES
, PROPERTY_ID_PRIVILEGES
, PropertyAttribute::BOUND
| PropertyAttribute::READONLY
,
276 &m_nPrivileges
, ::getCppuType(static_cast<sal_Int32
*>(NULL
)));
278 registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR
, PROPERTY_ID_TEXTLINECOLOR
, PropertyAttribute::BOUND
| PropertyAttribute::MAYBEVOID
,
279 &m_aTextLineColor
, ::getCppuType(static_cast<sal_Int32
*>(NULL
)));
281 registerProperty(PROPERTY_TEXTEMPHASIS
, PROPERTY_ID_TEXTEMPHASIS
, PropertyAttribute::BOUND
,
282 &m_nFontEmphasis
, ::getCppuType(&m_nFontEmphasis
));
284 registerProperty(PROPERTY_TEXTRELIEF
, PROPERTY_ID_TEXTRELIEF
, PropertyAttribute::BOUND
,
285 &m_nFontRelief
, ::getCppuType(&m_nFontRelief
));
287 registerProperty(PROPERTY_FONTNAME
, PROPERTY_ID_FONTNAME
, PropertyAttribute::BOUND
,&m_aFont
.Name
, ::getCppuType(&m_aFont
.Name
));
288 registerProperty(PROPERTY_FONTHEIGHT
, PROPERTY_ID_FONTHEIGHT
, PropertyAttribute::BOUND
,&m_aFont
.Height
, ::getCppuType(&m_aFont
.Height
));
289 registerProperty(PROPERTY_FONTWIDTH
, PROPERTY_ID_FONTWIDTH
, PropertyAttribute::BOUND
,&m_aFont
.Width
, ::getCppuType(&m_aFont
.Width
));
290 registerProperty(PROPERTY_FONTSTYLENAME
, PROPERTY_ID_FONTSTYLENAME
, PropertyAttribute::BOUND
,&m_aFont
.StyleName
, ::getCppuType(&m_aFont
.StyleName
));
291 registerProperty(PROPERTY_FONTFAMILY
, PROPERTY_ID_FONTFAMILY
, PropertyAttribute::BOUND
,&m_aFont
.Family
, ::getCppuType(&m_aFont
.Family
));
292 registerProperty(PROPERTY_FONTCHARSET
, PROPERTY_ID_FONTCHARSET
, PropertyAttribute::BOUND
,&m_aFont
.CharSet
, ::getCppuType(&m_aFont
.CharSet
));
293 registerProperty(PROPERTY_FONTPITCH
, PROPERTY_ID_FONTPITCH
, PropertyAttribute::BOUND
,&m_aFont
.Pitch
, ::getCppuType(&m_aFont
.Pitch
));
294 registerProperty(PROPERTY_FONTCHARWIDTH
, PROPERTY_ID_FONTCHARWIDTH
, PropertyAttribute::BOUND
,&m_aFont
.CharacterWidth
, ::getCppuType(&m_aFont
.CharacterWidth
));
295 registerProperty(PROPERTY_FONTWEIGHT
, PROPERTY_ID_FONTWEIGHT
, PropertyAttribute::BOUND
,&m_aFont
.Weight
, ::getCppuType(&m_aFont
.Weight
));
296 registerProperty(PROPERTY_FONTSLANT
, PROPERTY_ID_FONTSLANT
, PropertyAttribute::BOUND
,&m_aFont
.Slant
, ::getCppuType(&m_aFont
.Slant
));
297 registerProperty(PROPERTY_FONTUNDERLINE
, PROPERTY_ID_FONTUNDERLINE
, PropertyAttribute::BOUND
,&m_aFont
.Underline
, ::getCppuType(&m_aFont
.Underline
));
298 registerProperty(PROPERTY_FONTSTRIKEOUT
, PROPERTY_ID_FONTSTRIKEOUT
, PropertyAttribute::BOUND
,&m_aFont
.Strikeout
, ::getCppuType(&m_aFont
.Strikeout
));
299 registerProperty(PROPERTY_FONTORIENTATION
, PROPERTY_ID_FONTORIENTATION
, PropertyAttribute::BOUND
,&m_aFont
.Orientation
, ::getCppuType(&m_aFont
.Orientation
));
300 registerProperty(PROPERTY_FONTKERNING
, PROPERTY_ID_FONTKERNING
, PropertyAttribute::BOUND
,&m_aFont
.Kerning
, ::getCppuType(&m_aFont
.Kerning
));
301 registerProperty(PROPERTY_FONTWORDLINEMODE
, PROPERTY_ID_FONTWORDLINEMODE
,PropertyAttribute::BOUND
,&m_aFont
.WordLineMode
, ::getCppuType(&m_aFont
.WordLineMode
));
302 registerProperty(PROPERTY_FONTTYPE
, PROPERTY_ID_FONTTYPE
, PropertyAttribute::BOUND
,&m_aFont
.Type
, ::getCppuType(&m_aFont
.Type
));
306 // -----------------------------------------------------------------------------
307 ::cppu::IPropertyArrayHelper
* ODBTable::createArrayHelper( sal_Int32 _nId
) const
309 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createArrayHelper" );
310 Sequence
< Property
> aProps
;
311 describeProperties(aProps
);
314 Property
* pBegin
= aProps
.getArray();
315 Property
* pEnd
= pBegin
+ aProps
.getLength();
316 for(;pBegin
!= pEnd
;++pBegin
)
318 if (0 == pBegin
->Name
.compareToAscii(PROPERTY_CATALOGNAME
))
319 pBegin
->Attributes
= PropertyAttribute::READONLY
;
320 else if (0 == pBegin
->Name
.compareToAscii(PROPERTY_SCHEMANAME
))
321 pBegin
->Attributes
= PropertyAttribute::READONLY
;
322 else if (0 == pBegin
->Name
.compareToAscii(PROPERTY_DESCRIPTION
))
323 pBegin
->Attributes
= PropertyAttribute::READONLY
;
324 else if (0 == pBegin
->Name
.compareToAscii(PROPERTY_NAME
))
325 pBegin
->Attributes
= PropertyAttribute::READONLY
;
329 return new ::cppu::OPropertyArrayHelper(aProps
);
331 // -----------------------------------------------------------------------------
332 ::cppu::IPropertyArrayHelper
& SAL_CALL
ODBTable::getInfoHelper()
334 return *ODBTable_PROP::getArrayHelper(isNew() ? 1 : 0);
336 // -------------------------------------------------------------------------
338 IMPLEMENT_SERVICE_INFO1(ODBTable
, "com.sun.star.sdb.dbaccess.ODBTable", SERVICE_SDBCX_TABLE
)
339 // -------------------------------------------------------------------------
340 Any SAL_CALL
ODBTable::queryInterface( const Type
& rType
) throw(RuntimeException
)
342 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getInfoHelper" );
344 if(rType
== getCppuType( (Reference
<XRename
>*)0))
346 if(rType
== getCppuType( (Reference
<XAlterTable
>*)0))
348 aRet
= OTable_Base::queryInterface( rType
);
352 // -------------------------------------------------------------------------
353 Sequence
< Type
> SAL_CALL
ODBTable::getTypes( ) throw(RuntimeException
)
355 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getTypes" );
356 Type aRenameType
= getCppuType( (Reference
<XRename
>*)0);
357 Type aAlterType
= getCppuType( (Reference
<XAlterTable
>*)0);
359 Sequence
< Type
> aTypes(OTable_Base::getTypes());
360 ::std::vector
<Type
> aOwnTypes
;
361 aOwnTypes
.reserve(aTypes
.getLength());
363 const Type
* pBegin
= aTypes
.getConstArray();
364 const Type
* pEnd
= pBegin
+ aTypes
.getLength();
365 for(;pBegin
!= pEnd
;++pBegin
)
367 if(*pBegin
!= aRenameType
&& *pBegin
!= aAlterType
)
368 aOwnTypes
.push_back(*pBegin
);
371 Type
* pTypes
= aOwnTypes
.empty() ? 0 : &aOwnTypes
[0];
372 return Sequence
< Type
>(pTypes
, aOwnTypes
.size());
375 //------------------------------------------------------------------------------
376 void SAL_CALL
ODBTable::rename( const ::rtl::OUString
& /*_rNewName*/ ) throw(SQLException
, ElementExistException
, RuntimeException
)
378 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::rename" );
379 throw SQLException(DBACORE_RESSTRING(RID_STR_NO_TABLE_RENAME
),*this,SQLSTATE_GENERAL
,1000,Any() );
383 //------------------------------------------------------------------------------
384 void SAL_CALL
ODBTable::alterColumnByName( const ::rtl::OUString
& _rName
, const Reference
< XPropertySet
>& _rxDescriptor
) throw(SQLException
, NoSuchElementException
, RuntimeException
)
386 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::alterColumnByName" );
387 ::osl::MutexGuard
aGuard(m_aMutex
);
389 connectivity::sdbcx::OTableDescriptor_BASE::rBHelper
.bDisposed
);
390 if(m_pColumns
->hasByName(_rName
))
392 ::rtl::OUString sSql
= ::rtl::OUString::createFromAscii("ALTER TABLE ");
393 ::rtl::OUString aQuote
;
394 Reference
<XDatabaseMetaData
> xMeta
= getMetaData();
396 aQuote
= xMeta
->getIdentifierQuoteString( );
397 ::rtl::OUString sComposedName
;
399 sComposedName
= ::dbtools::composeTableName( xMeta
, m_CatalogName
, m_SchemaName
, m_Name
, sal_True
, ::dbtools::eInTableDefinitions
);
400 if(!sComposedName
.getLength())
401 ::dbtools::throwFunctionSequenceException(*this);
403 sSql
+= sComposedName
;
404 sSql
+= ::rtl::OUString::createFromAscii(" ALTER ");
405 sSql
+= ::dbtools::quoteName(aQuote
,_rName
);
407 ::rtl::OUString sNewDefaultValue
,sDefaultValue
;
409 Reference
<XPropertySet
> xColumn
;
410 m_pColumns
->getByName(_rName
) >>= xColumn
;
411 if(_rxDescriptor
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE
))
412 _rxDescriptor
->getPropertyValue(PROPERTY_DEFAULTVALUE
) >>= sNewDefaultValue
;
413 if(xColumn
.is() && xColumn
->getPropertySetInfo()->hasPropertyByName(PROPERTY_DEFAULTVALUE
))
414 xColumn
->getPropertyValue(PROPERTY_DEFAULTVALUE
) >>= sDefaultValue
;
416 if(sNewDefaultValue
!= sDefaultValue
&& getMetaData().is() )
418 if(sNewDefaultValue
.getLength())
420 sSql
+= ::rtl::OUString::createFromAscii(" SET DEFAULT ");
421 sSql
+= sNewDefaultValue
;
424 sSql
+= ::rtl::OUString::createFromAscii(" DROP DEFAULT");
425 OSL_ENSURE(getMetaData()->getConnection().is(),"Connection is null!");
426 Reference
< XStatement
> xStmt
= getMetaData()->getConnection()->createStatement( );
428 xStmt
->execute(sSql
);
432 throw SQLException(DBACORE_RESSTRING(RID_STR_NO_ALTER_COLUMN_DEF
),*this,SQLSTATE_GENERAL
,1000,Any() );
436 throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_ALTER_BY_NAME
),*this,SQLSTATE_GENERAL
,1000,Any() );
437 m_pColumns
->refresh();
439 // -----------------------------------------------------------------------------
440 sal_Int64 SAL_CALL
ODBTable::getSomething( const Sequence
< sal_Int8
>& rId
) throw(RuntimeException
)
442 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getSomething" );
444 if (rId
.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId
.getConstArray(), 16 ) )
445 nRet
= reinterpret_cast<sal_Int64
>(this);
447 nRet
= OTable_Base::getSomething(rId
);
451 // -----------------------------------------------------------------------------
452 Sequence
< sal_Int8
> ODBTable::getUnoTunnelImplementationId()
454 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::getUnoTunnelImplementationId" );
455 static ::cppu::OImplementationId
* pId
= 0;
458 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
461 static ::cppu::OImplementationId aId
;
465 return pId
->getImplementationId();
467 // -----------------------------------------------------------------------------
468 Reference
< XPropertySet
> ODBTable::createColumnDescriptor()
470 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumnDescriptor" );
471 return new OTableColumnDescriptor();
473 // -----------------------------------------------------------------------------
474 sdbcx::OCollection
* ODBTable::createColumns(const TStringVector
& _rNames
)
476 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createColumns" );
477 Reference
<XDatabaseMetaData
> xMeta
= getMetaData();
478 OColumns
* pCol
= new OColumns(*this, m_aMutex
, NULL
, isCaseSensitive(), _rNames
, this,this,
479 xMeta
.is() && xMeta
->supportsAlterTableWithAddColumn(),
480 xMeta
.is() && xMeta
->supportsAlterTableWithDropColumn());
481 static_cast<OColumnsHelper
*>(pCol
)->setParent(this);
482 pCol
->setParent(*this);
483 m_pColumnMediator
= new OContainerMediator( pCol
, m_xColumnDefinitions
, getConnection(), OContainerMediator::eColumns
);
484 pCol
->setMediator( m_pColumnMediator
.get() );
487 // -----------------------------------------------------------------------------
488 sdbcx::OCollection
* ODBTable::createKeys(const TStringVector
& _rNames
)
490 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createKeys" );
491 return new connectivity::OKeysHelper(this,m_aMutex
,_rNames
);
493 // -----------------------------------------------------------------------------
494 sdbcx::OCollection
* ODBTable::createIndexes(const TStringVector
& _rNames
)
496 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "ODBTable::createIndexes" );
497 return new OIndexes(this,m_aMutex
,_rNames
,NULL
);
499 // -----------------------------------------------------------------------------