diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-04-11 05:21:33 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-04-11 05:21:33 +0000 |
commit | 33579b1d327263a562b916af485592ee13620f54 (patch) | |
tree | 8816843462c3e6e9a4b6199d94b376722b4352fc /dbaccess/source | |
parent | 99e91f8a85e06895260021b1115d74e1f4da7c0e (diff) |
check if order of columns is correct
Diffstat (limited to 'dbaccess/source')
-rw-r--r-- | dbaccess/source/core/api/querycomposer.cxx | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/dbaccess/source/core/api/querycomposer.cxx b/dbaccess/source/core/api/querycomposer.cxx index 1557b2bd0138..e198f290da92 100644 --- a/dbaccess/source/core/api/querycomposer.cxx +++ b/dbaccess/source/core/api/querycomposer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: querycomposer.cxx,v $ * - * $Revision: 1.28 $ + * $Revision: 1.29 $ * - * last change: $Author: jl $ $Date: 2001-03-23 13:18:50 $ + * last change: $Author: oj $ $Date: 2001-04-11 06:21:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,12 @@ #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ #include <com/sun/star/sdbc/DataType.hpp> #endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATA_HPP_ +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#endif #ifndef _COM_SUN_STAR_REGISTRY_XSIMPLEREGISTRY_HPP_ #include <com/sun/star/registry/XSimpleRegistry.hpp> #endif @@ -427,11 +433,43 @@ void SAL_CALL OQueryComposer::setQuery( const ::rtl::OUString& command ) throw(S delete m_pParameters; m_pParameters = NULL; } - // now set the columns - const ::vos::ORef< OSQLColumns>& aCols = m_aSqlIterator.getSelectColumns(); + // now set the columns we have to look if the order of the columns is correct + Reference<XStatement> xStmt = m_xConnection->createStatement(); + ::std::vector< ::rtl::OUString> aNames; - for(OSQLColumns::const_iterator aIter = aCols->begin(); aIter != aCols->end();++aIter) - aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); + const ::vos::ORef< OSQLColumns>& aCols = m_aSqlIterator.getSelectColumns(); + if(xStmt.is()) + { + ::rtl::OUString sSql = m_aWorkSql; + sSql += STR_WHERE; + sSql += ::rtl::OUString::createFromAscii(" 0 = 1"); + + Reference<XResultSetMetaDataSupplier> xResMetaDataSup; + xResMetaDataSup = Reference<XResultSetMetaDataSupplier>(xStmt->executeQuery(sSql),UNO_QUERY); + Reference<XResultSetMetaData> xMeta = xResMetaDataSup->getMetaData(); + + sal_Int32 nCount = xMeta.is() ? xMeta->getColumnCount() : sal_Int32(0); + ::comphelper::UStringMixEqual bCase(m_xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + for(sal_Int32 i=1;i<=nCount;++i) + { + ::rtl::OUString sName = xMeta->getColumnName(i); + OSQLColumns::const_iterator aFind = ::connectivity::find(aCols->begin(),aCols->end(),sName,bCase); + if(aFind != aCols->end()) + aNames.push_back(sName); + else + { // we can now only look if we found it under the realname propertery + aFind = ::connectivity::findRealName(aCols->begin(),aCols->end(),sName,bCase); + if(aFind != aCols->end()) + aNames.push_back(sName); + } + } + ::comphelper::disposeComponent(xStmt); + } + else + { + for(OSQLColumns::const_iterator aIter = aCols->begin(); aIter != aCols->end();++aIter) + aNames.push_back(getString((*aIter)->getPropertyValue(PROPERTY_NAME))); + } m_pColumns = new OPrivateColumns(*aCols,m_xConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames); getTables(); |