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