1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "adabas/BTables.hxx"
27 #include "adabas/BViews.hxx"
28 #include "adabas/BTable.hxx"
29 #include <com/sun/star/sdbc/XRow.hpp>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/sdbc/ColumnValue.hpp>
32 #include <com/sun/star/sdbc/KeyRule.hpp>
33 #include <com/sun/star/sdbcx/KeyType.hpp>
34 #include "adabas/BCatalog.hxx"
35 #include "adabas/BConnection.hxx"
36 #include <comphelper/extract.hxx>
37 #include "connectivity/dbtools.hxx"
38 #include "connectivity/dbexception.hxx"
39 #include <cppuhelper/interfacecontainer.h>
40 #include <comphelper/types.hxx>
41
42 using namespace ::comphelper;
43 using namespace connectivity;
44 using namespace ::cppu;
45 using namespace connectivity::adabas;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::beans;
48 using namespace ::com::sun::star::sdbcx;
49 using namespace ::com::sun::star::sdbc;
50 using namespace ::com::sun::star::container;
51 using namespace ::com::sun::star::lang;
52 using namespace dbtools;
53 typedef connectivity::sdbcx::OCollection OCollection_TYPE;
54
createObject(const::rtl::OUString & _rName)55 sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
56 {
57 ::rtl::OUString aName,aSchema;
58 sal_Int32 nLen = _rName.indexOf('.');
59 aSchema = _rName.copy(0,nLen);
60 aName = _rName.copy(nLen+1);
61
62 Sequence< ::rtl::OUString > aTypes(1);
63 aTypes[0] = ::rtl::OUString::createFromAscii("%");
64 // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
65 // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE");
66
67 Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
68
69 sdbcx::ObjectType xRet = NULL;
70 if(xResult.is())
71 {
72 Reference< XRow > xRow(xResult,UNO_QUERY);
73 if(xResult->next()) // there can be only one table with this name
74 {
75 OAdabasTable* pRet = new OAdabasTable(this, static_cast<OAdabasCatalog&>(m_rParent).getConnection(),
76 aName,xRow->getString(4),xRow->getString(5),aSchema);
77 xRet = pRet;
78 }
79 ::comphelper::disposeComponent(xResult);
80 }
81
82 return xRet;
83 }
84 // -------------------------------------------------------------------------
impl_refresh()85 void OTables::impl_refresh( ) throw(RuntimeException)
86 {
87 static_cast<OAdabasCatalog&>(m_rParent).refreshTables();
88 }
89 // -------------------------------------------------------------------------
disposing(void)90 void OTables::disposing(void)
91 {
92 m_xMetaData.clear();
93 OCollection::disposing();
94 }
95 // -------------------------------------------------------------------------
createDescriptor()96 Reference< XPropertySet > OTables::createDescriptor()
97 {
98 return new OAdabasTable(this,static_cast<OAdabasCatalog&>(m_rParent).getConnection());
99 }
100 // -------------------------------------------------------------------------
101 // XAppend
appendObject(const::rtl::OUString & _rForName,const Reference<XPropertySet> & descriptor)102 sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
103 {
104 createTable(descriptor);
105 return createObject( _rForName );
106 }
107 // -------------------------------------------------------------------------
setComments(const Reference<XPropertySet> & descriptor)108 void OTables::setComments(const Reference< XPropertySet >& descriptor ) throw(SQLException, RuntimeException)
109 {
110 ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
111 ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
112 const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
113
114 OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
115 Reference< XStatement > xStmt = pConnection->createStatement( );
116 aSql = ::rtl::OUString::createFromAscii("COMMENT ON TABLE ");
117 ::rtl::OUString sSchema;
118 descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
119 if(sSchema.getLength())
120 aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
121
122 aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
123 + ::rtl::OUString::createFromAscii(" '")
124 + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
125 + ::rtl::OUString::createFromAscii("'");
126 xStmt->execute(aSql);
127
128 // columns
129 Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
130 Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
131 Reference< XPropertySet > xColProp;
132
133 aSql = ::rtl::OUString::createFromAscii("COMMENT ON COLUMN ");
134 if(sSchema.getLength())
135 aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
136 aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote + sDot
137 + aQuote;
138
139 for(sal_Int32 i=0;i<xColumns->getCount();++i)
140 {
141 ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
142 if(xColProp.is())
143 {
144 ::rtl::OUString aDescription = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)));
145 if(aDescription.getLength())
146 {
147 ::rtl::OUString aCom = aSql + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
148 + ::rtl::OUString::createFromAscii(" '")
149 + aDescription
150 + ::rtl::OUString::createFromAscii("'");
151 xStmt->execute(aSql);
152 ::comphelper::disposeComponent(xStmt);
153 }
154 }
155 }
156 ::comphelper::disposeComponent(xStmt);
157 }
158 // -------------------------------------------------------------------------
159 // XDrop
dropObject(sal_Int32 _nPos,const::rtl::OUString _sElementName)160 void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
161 {
162 Reference< XInterface > xObject( getObject( _nPos ) );
163 sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
164 if (!bIsNew)
165 {
166 OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
167 Reference< XStatement > xStmt = pConnection->createStatement( );
168
169 ::rtl::OUString aName,aSchema;
170 sal_Int32 nLen = _sElementName.indexOf('.');
171 aSchema = _sElementName.copy(0,nLen);
172 aName = _sElementName.copy(nLen+1);
173 ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
174 const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
175
176 Reference<XPropertySet> xProp(xObject,UNO_QUERY);
177 sal_Bool bIsView;
178 if((bIsView = (xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == ::rtl::OUString::createFromAscii("VIEW")))) // here we have a view
179 aSql += ::rtl::OUString::createFromAscii("VIEW ");
180 else
181 aSql += ::rtl::OUString::createFromAscii("TABLE ");
182
183 aSql += m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( );
184 aSql += sDot;
185 aSql += m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( );
186 xStmt->execute(aSql);
187 ::comphelper::disposeComponent(xStmt);
188 // if no exception was thrown we must delete it from the views
189 if(bIsView)
190 {
191 OViews* pViews = static_cast<OViews*>(static_cast<OAdabasCatalog&>(m_rParent).getPrivateViews());
192 if(pViews && pViews->hasByName(_sElementName))
193 pViews->dropByNameImpl(_sElementName);
194 }
195 }
196 }
197 // -------------------------------------------------------------------------
createTable(const Reference<XPropertySet> & descriptor)198 void OTables::createTable( const Reference< XPropertySet >& descriptor )
199 {
200 ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
201 ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
202 const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
203 ::rtl::OUString sSchema;
204
205 descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
206 if(sSchema.getLength())
207 aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
208 else
209 descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),makeAny(static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getUserName().
210 toAsciiUpperCase()
211 ));
212
213 aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))
214 + ::rtl::OUString::createFromAscii(" (");
215
216 // columns
217 Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
218 Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
219 Reference< XPropertySet > xColProp;
220
221 Any aTypeName;
222 sal_Int32 nCount = xColumns->getCount();
223 if(!nCount)
224 ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(this));
225
226 for(sal_Int32 i=0;i<nCount;++i)
227 {
228 if(::cppu::extractInterface(xColProp,xColumns->getByIndex(i)) && xColProp.is())
229 {
230
231 aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
232
233 aSql += ::rtl::OUString::createFromAscii(" ");
234 aSql += OTables::getColumnSqlType(xColProp);
235 aSql += OTables::getColumnSqlNotNullDefault(xColProp);
236 aSql += ::rtl::OUString::createFromAscii(",");
237 }
238 }
239
240 // keys
241
242 Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY);
243
244 Reference<XIndexAccess> xKeys = xKeySup->getKeys();
245 if(xKeys.is())
246 {
247 sal_Bool bPKey = sal_False;
248 for( sal_Int32 key=0; key<xKeys->getCount(); ++key )
249 {
250 if(::cppu::extractInterface(xColProp,xKeys->getByIndex(key)) && xColProp.is())
251 {
252
253 sal_Int32 nKeyType = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
254
255 if(nKeyType == KeyType::PRIMARY)
256 {
257 if(bPKey)
258 throw SQLException();
259
260 bPKey = sal_True;
261 xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
262 xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
263 if(!xColumns->getCount())
264 throw SQLException();
265
266 aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY (");
267 for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
268 {
269 if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
270 aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
271 + ::rtl::OUString::createFromAscii(",");
272 }
273
274 aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
275 }
276 else if(nKeyType == KeyType::UNIQUE)
277 {
278 xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
279 xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
280 if(!xColumns->getCount())
281 throw SQLException();
282
283 aSql += ::rtl::OUString::createFromAscii(" UNIQUE (");
284 for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
285 {
286 if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
287 aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
288 + ::rtl::OUString::createFromAscii(",");
289 }
290
291 aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
292 }
293 else if(nKeyType == KeyType::FOREIGN)
294 {
295 sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE)));
296
297 xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
298 xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
299 if(!xColumns->getCount())
300 throw SQLException();
301
302 aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY ");
303 ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
304 sal_Int32 nLen = aRefTable.indexOf('.');
305 aSchema = aRefTable.copy(0,nLen);
306 aName = aRefTable.copy(nLen+1);
307
308 aSql += aQuote + aSchema + aQuote + sDot
309 + aQuote + aName + aQuote
310 + ::rtl::OUString::createFromAscii(" (");
311
312 for ( sal_Int32 column=0; column<xColumns->getCount(); ++column )
313 {
314 if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
315 aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
316 + ::rtl::OUString::createFromAscii(",");
317 }
318
319 aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
320
321 switch(nDeleteRule)
322 {
323 case KeyRule::CASCADE:
324 aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE ");
325 break;
326 case KeyRule::RESTRICT:
327 aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ");
328 break;
329 case KeyRule::SET_NULL:
330 aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL ");
331 break;
332 case KeyRule::SET_DEFAULT:
333 aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ");
334 break;
335 default:
336 ;
337 }
338 }
339 }
340 }
341 }
342
343 if(aSql.lastIndexOf(',') == (aSql.getLength()-1))
344 aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
345 else
346 aSql += ::rtl::OUString::createFromAscii(")");
347
348 OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
349 Reference< XStatement > xStmt = pConnection->createStatement( );
350 xStmt->execute(aSql);
351 ::comphelper::disposeComponent(xStmt);
352
353 if(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))).getLength())
354 setComments(descriptor);
355 }
356 // -----------------------------------------------------------------------------
appendNew(const::rtl::OUString & _rsNewTable)357 void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
358 {
359 insertElement(_rsNewTable,NULL);
360
361 // notify our container listeners
362 ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
363 OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
364 while (aListenerLoop.hasMoreElements())
365 static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
366 }
367 // -----------------------------------------------------------------------------
getColumnSqlType(const Reference<XPropertySet> & _rxColProp)368 ::rtl::OUString OTables::getColumnSqlType(const Reference<XPropertySet>& _rxColProp)
369 {
370 ::rtl::OUString sSql;
371 sal_Int32 nDataType = 0;
372 _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nDataType;
373 switch(nDataType)
374 {
375 case DataType::VARBINARY:
376 sSql += ::rtl::OUString::createFromAscii("VAR");
377 /* run through*/
378 case DataType::BINARY:
379 sSql += ::rtl::OUString::createFromAscii("CHAR");
380 break;
381 default:
382 {
383 Any aTypeName = _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
384 if(aTypeName.hasValue() && getString(aTypeName).getLength())
385 sSql += getString(aTypeName);
386 else
387 sSql += OTables::getTypeString(_rxColProp) + ::rtl::OUString::createFromAscii(" ");
388 }
389 }
390
391 switch(nDataType)
392 {
393 case DataType::CHAR:
394 case DataType::VARCHAR:
395 case DataType::FLOAT:
396 case DataType::REAL:
397 sSql += ::rtl::OUString::createFromAscii("(")
398 + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
399 + ::rtl::OUString::createFromAscii(")");
400 break;
401
402 case DataType::DECIMAL:
403 case DataType::NUMERIC:
404 sSql += ::rtl::OUString::createFromAscii("(")
405 + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
406 + ::rtl::OUString::createFromAscii(",")
407 + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))))
408 + ::rtl::OUString::createFromAscii(")");
409 break;
410 case DataType::BINARY:
411 case DataType::VARBINARY:
412 sSql += ::rtl::OUString::createFromAscii("(")
413 + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
414 + ::rtl::OUString::createFromAscii(") BYTE");
415 break;
416 }
417 return sSql;
418 }
419 // -----------------------------------------------------------------------------
getColumnSqlNotNullDefault(const Reference<XPropertySet> & _rxColProp)420 ::rtl::OUString OTables::getColumnSqlNotNullDefault(const Reference<XPropertySet>& _rxColProp)
421 {
422 OSL_ENSURE(_rxColProp.is(),"OTables::getColumnSqlNotNullDefault: Column is null!");
423 ::rtl::OUString sSql;
424 ::rtl::OUString aDefault = getString(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
425 if(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS)
426 {
427 sSql += ::rtl::OUString::createFromAscii(" NOT NULL");
428 if(aDefault.getLength())
429 sSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT");
430 }
431 else if(aDefault.getLength())
432 {
433 sSql +=::rtl::OUString::createFromAscii(" DEFAULT '") + aDefault;
434 sSql += ::rtl::OUString::createFromAscii("'");
435 }
436 return sSql;
437 }
438 // -----------------------------------------------------------------------------
getTypeString(const Reference<XPropertySet> & _rxColProp)439 ::rtl::OUString OTables::getTypeString(const Reference< XPropertySet >& _rxColProp)
440 {
441 ::rtl::OUString aValue;
442 switch(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
443 {
444 case DataType::BIT:
445 aValue = ::rtl::OUString::createFromAscii("BOOLEAN");
446 break;
447 case DataType::TINYINT:
448 aValue = ::rtl::OUString::createFromAscii("SMALLINT");
449 break;
450 case DataType::SMALLINT:
451 aValue = ::rtl::OUString::createFromAscii("SMALLINT");
452 break;
453 case DataType::INTEGER:
454 aValue = ::rtl::OUString::createFromAscii("INT");
455 break;
456 case DataType::FLOAT:
457 aValue = ::rtl::OUString::createFromAscii("FLOAT");
458 break;
459 case DataType::REAL:
460 aValue = ::rtl::OUString::createFromAscii("REAL");
461 break;
462 case DataType::DOUBLE:
463 aValue = ::rtl::OUString::createFromAscii("DOUBLE");
464 break;
465 case DataType::NUMERIC:
466 aValue = ::rtl::OUString::createFromAscii("DECIMAL");
467 break;
468 case DataType::DECIMAL:
469 aValue = ::rtl::OUString::createFromAscii("DECIMAL");
470 break;
471 case DataType::CHAR:
472 aValue = ::rtl::OUString::createFromAscii("CHAR");
473 break;
474 case DataType::VARCHAR:
475 aValue = ::rtl::OUString::createFromAscii("VARCHAR");
476 break;
477 case DataType::LONGVARCHAR:
478 aValue = ::rtl::OUString::createFromAscii("LONG VARCHAR");
479 break;
480 case DataType::DATE:
481 aValue = ::rtl::OUString::createFromAscii("DATE");
482 break;
483 case DataType::TIME:
484 aValue = ::rtl::OUString::createFromAscii("TIME");
485 break;
486 case DataType::TIMESTAMP:
487 aValue = ::rtl::OUString::createFromAscii("TIMESTAMP");
488 break;
489 case DataType::BINARY:
490 aValue = ::rtl::OUString::createFromAscii("CHAR () BYTE");
491 break;
492 case DataType::VARBINARY:
493 aValue = ::rtl::OUString::createFromAscii("VARCHAR () BYTE");
494 break;
495 case DataType::LONGVARBINARY:
496 aValue = ::rtl::OUString::createFromAscii("LONG BYTE");
497 break;
498 }
499 return aValue;
500 }
501 // -----------------------------------------------------------------------------
getNameForObject(const sdbcx::ObjectType & _xObject)502 ::rtl::OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
503 {
504 OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
505 ::rtl::OUString sName,sTemp;
506 _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sName;
507 if( sName.getLength() )
508 {
509 const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
510 sName += sDot;
511 }
512
513 _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sTemp;
514 sName += sTemp;
515
516 return sName;
517 }
518 // -----------------------------------------------------------------------------
519