diff options
author | Ocke Janssen <oj@openoffice.org> | 2002-11-07 07:43:37 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2002-11-07 07:43:37 +0000 |
commit | 6cf9489d90f942fcdfb399410aab6d9175688bf8 (patch) | |
tree | 71ca22e874b6f15f66b04cf2d0501a4d9e7c249e /connectivity | |
parent | 667e4ce453196687e19c12daf77a89c076f24740 (diff) |
#104781# use and impl of new method
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/TKeys.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools2.cxx | 59 |
2 files changed, 52 insertions, 17 deletions
diff --git a/connectivity/source/commontools/TKeys.cxx b/connectivity/source/commontools/TKeys.cxx index 595acaf7bea8..ad51821eabd1 100644 --- a/connectivity/source/commontools/TKeys.cxx +++ b/connectivity/source/commontools/TKeys.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TKeys.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2002-10-25 09:00:29 $ + * last change: $Author: oj $ $Date: 2002-11-07 08:43:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -306,14 +306,12 @@ void OKeysHelper::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName ObjectIter aIter = m_aElements[_nPos]; if(!aIter->second.is()) // we want to drop a object which isn't loaded yet so we must load it aIter->second = createObject(_sElementName); + Reference<XPropertySet> xKey(aIter->second,UNO_QUERY); - sal_Int32 nKeyType = 0; - ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap(); - xKey->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_TYPE)) >>= nKeyType; aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP CONSTRAINT ")); ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString(); - aSql += aQuote + _sElementName + aQuote; + aSql += ::dbtools::quoteName( aQuote,_sElementName); Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); if ( xStmt.is() ) diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 2f84ac9a71fc..e46d707c3d20 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbtools2.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2002-10-25 09:00:00 $ + * last change: $Author: oj $ $Date: 2002-11-07 08:43:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -169,18 +169,35 @@ namespace dbtools } } - aSql += sTypeName; - if(nPrecision > 0 && bUseLiteral) + + if ( nPrecision > 0 && bUseLiteral ) { - aSql += ::rtl::OUString::createFromAscii("("); + sal_Int32 nParenPos = sTypeName.indexOf('('); + if ( nParenPos == -1 ) + { + aSql += sTypeName; + aSql += ::rtl::OUString::createFromAscii("("); + } + else + { + aSql += sTypeName.copy(0,++nParenPos); + } aSql += ::rtl::OUString::valueOf(nPrecision); - if(nScale > 0) + if ( nScale > 0 ) { aSql += ::rtl::OUString::createFromAscii(","); aSql += ::rtl::OUString::valueOf(nScale); } - aSql += ::rtl::OUString::createFromAscii(")"); + if ( nParenPos == -1 ) + aSql += ::rtl::OUString::createFromAscii(")"); + else + { + nParenPos = sTypeName.indexOf(')',nParenPos); + aSql += sTypeName.copy(nParenPos); + } } + else + aSql += sTypeName; // simply add the type name ::rtl::OUString aDefault = ::comphelper::getString(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); if(aDefault.getLength()) @@ -365,15 +382,35 @@ namespace dbtools } } - if(aSql.lastIndexOf(',') == (aSql.getLength()-1)) - aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); - else - aSql += ::rtl::OUString::createFromAscii(")"); + if ( aSql.getLength() ) + { + if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) ) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + else + aSql += ::rtl::OUString::createFromAscii(")"); + } return aSql; } // ----------------------------------------------------------------------------- +::rtl::OUString createSqlCreateTableStatement( const Reference< XPropertySet >& descriptor, + const Reference< XConnection>& _xConnection) +{ + ::rtl::OUString aSql = ::dbtools::createStandardCreateStatement(descriptor,_xConnection); + ::rtl::OUString sKeyStmt = ::dbtools::createStandardKeyStatement(descriptor,_xConnection); + if ( sKeyStmt.getLength() ) + aSql += sKeyStmt; + else + { + if ( aSql.lastIndexOf(',') == (aSql.getLength()-1) ) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + else + aSql += ::rtl::OUString::createFromAscii(")"); + } + return aSql; +} +// ----------------------------------------------------------------------------- Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable, const Reference<XConnection>& _xConnection, const ::rtl::OUString& _rName, |