Tag: cws_src680_dba25 User: oj Date: 05/03/07 23:57:09 Modified: /dba/connectivity/source/commontools/ TIndexes.cxx
Log: #i44320# correct the get for unique File Changes: Directory: /dba/connectivity/source/commontools/ ================================================ File [changed]: TIndexes.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/commontools/TIndexes.cxx?r1=1.3&r2=1.3.46.1 Delta lines: +30 -23 --------------------- --- TIndexes.cxx 22 Oct 2004 08:41:22 -0000 1.3 +++ TIndexes.cxx 8 Mar 2005 07:57:06 -0000 1.3.46.1 @@ -2,9 +2,9 @@ * * $RCSfile: TIndexes.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.3.46.1 $ * - * last change: $Author: rt $ $Date: 2004/10/22 08:41:22 $ + * last change: $Author: oj $ $Date: 2005/03/08 07:57:06 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -85,6 +85,9 @@ #ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> #endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif using namespace connectivity; using namespace connectivity::sdbcx; @@ -169,13 +172,13 @@ if(!m_pTable->isNew()) { - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE "); + ::rtl::OUStringBuffer aSql( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATE "))); ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( ); ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); - if(comphelper::getINT32(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE)))) - aSql = aSql + ::rtl::OUString::createFromAscii("UNIQUE "); - aSql = aSql + ::rtl::OUString::createFromAscii("INDEX "); + if(comphelper::getBOOL(descriptor->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISUNIQUE)))) + aSql.appendAscii("UNIQUE "); + aSql.appendAscii("INDEX "); ::rtl::OUString aCatalog,aSchema,aTable; @@ -185,35 +188,37 @@ dbtools::composeTableName(m_pTable->getMetaData(),aCatalog,aSchema,aTable,aComposedName,sal_True,::dbtools::eInIndexDefinitions); if ( aName.getLength() ) { - aSql = aSql + ::dbtools::quoteName( aQuote,aName ) - + ::rtl::OUString::createFromAscii(" ON ") - + aComposedName - + ::rtl::OUString::createFromAscii(" ( "); + aSql.append(::dbtools::quoteName( aQuote,aName )); + aSql.appendAscii(" ON "); + aSql.append(aComposedName); + aSql.appendAscii(" ( "); Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); Reference< XPropertySet > xColProp; - for(sal_Int32 i=0;i<xColumns->getCount();++i) + sal_Bool bAddIndexAppendix = ::dbtools::isDataSourcePropertyEnabled(m_pTable->getConnection(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AddIndexAppendix")),sal_True); + sal_Int32 nCount = xColumns->getCount(); + for(sal_Int32 i = 0 ; i < nCount; ++i) { - ::cppu::extractInterface(xColProp,xColumns->getByIndex(i)); - aSql = aSql + ::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + xColProp.set(xColumns->getByIndex(i),UNO_QUERY); + aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))); - if ( ::dbtools::isDataSourcePropertyEnabled(m_pTable->getConnection(),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AddIndexAppendix")),sal_True) ) + if ( bAddIndexAppendix ) { - aSql += (any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING))) + aSql.appendAscii(any2bool(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISASCENDING))) ? - ::rtl::OUString::createFromAscii(" ASC") + " ASC" : - ::rtl::OUString::createFromAscii(" DESC")); + " DESC"); } - aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); + aSql.appendAscii(","); } - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + aSql.setCharAt(aSql.getLength()-1,')'); } else { - aSql = aSql + aComposedName; + aSql.append(aComposedName); Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); @@ -223,13 +228,15 @@ xColumns->getByIndex(0) >>= xColProp; - aSql = aSql + aDot + ::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)))); + aSql.append(aDot); + aSql.append(::dbtools::quoteName( aQuote,comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME))))); } Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); if ( xStmt.is() ) { - xStmt->execute(aSql); + ::rtl::OUString sSql = aSql.makeStringAndClear(); + xStmt->execute(sSql); ::comphelper::disposeComponent(xStmt); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
