diff options
author | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2010-09-01 13:09:46 +0200 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@oracle.com> | 2010-09-01 13:09:46 +0200 |
commit | 9bac46bf7bebcadfdbf4ee03a1e64650c950e036 (patch) | |
tree | b56bd85f4a805acd2a372b7f57d7e806d20cbc94 | |
parent | bf76cc893df69ecb3408e4fcf1321c171a039c57 (diff) |
dba33h: #i114246# use correct table name
-rw-r--r-- | dbaccess/source/core/api/KeySet.cxx | 31 | ||||
-rw-r--r-- | dbaccess/source/core/api/KeySet.hxx | 1 |
2 files changed, 25 insertions, 7 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx index eb1699f33..4d76accfc 100644 --- a/dbaccess/source/core/api/KeySet.cxx +++ b/dbaccess/source/core/api/KeySet.cxx @@ -198,7 +198,7 @@ void OKeySet::initColumns() m_pForeignColumnNames.reset( new SelectColumnsMetaData(bCase) ); } void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable - ,const Reference<XDatabaseMetaData>& /*i_xMeta*/ + ,const Reference<XDatabaseMetaData>& i_xMeta ,const Reference<XNameAccess>& i_xQueryColumns) { // first ask the database itself for the best columns which can be used @@ -209,9 +209,6 @@ void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable const Reference<XColumnsSupplier> xTblColSup(i_aTable,UNO_QUERY_THROW); const Reference<XNameAccess> xTblColumns = xTblColSup->getColumns(); - ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true); - ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true); - // locate parameter in select columns Reference<XParametersSupplier> xParaSup(m_xComposer,UNO_QUERY); Reference<XIndexAccess> xQueryParameters = xParaSup->getParameters(); @@ -222,7 +219,26 @@ void OKeySet::findTableColumnsMatching_throw(const Any& i_aTable Reference<XPropertySet> xPara(xQueryParameters->getByIndex(i),UNO_QUERY_THROW); xPara->getPropertyValue(PROPERTY_REALNAME) >>= aParameterColumns[i]; } - ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true); + + if ( m_sUpdateTableName.getLength() ) + { + ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,m_sUpdateTableName,(*m_pKeyColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),m_sUpdateTableName,(*m_pColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,m_sUpdateTableName,(*m_pParameterNames),true); + } + else + { + ::rtl::OUString sCatalog,sSchema,sTable; + Reference<XPropertySet> xTableProp(i_aTable,UNO_QUERY); + Any aCatalog = xTableProp->getPropertyValue(PROPERTY_CATALOGNAME); + aCatalog >>= sCatalog; + xTableProp->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; + xTableProp->getPropertyValue(PROPERTY_NAME) >>= sTable; + const ::rtl::OUString sComposedUpdateTableName = dbtools::composeTableName( i_xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); + ::dbaccess::getColumnPositions(i_xQueryColumns,aBestColumnNames,sComposedUpdateTableName,(*m_pKeyColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,xTblColumns->getElementNames(),sComposedUpdateTableName,(*m_pColumnNames),true); + ::dbaccess::getColumnPositions(i_xQueryColumns,aParameterColumns,sComposedUpdateTableName,(*m_pParameterNames),true); + } SelectColumnsMetaData::const_iterator aPosIter = m_pKeyColumnNames->begin(); SelectColumnsMetaData::const_iterator aPosEnd = m_pKeyColumnNames->end(); @@ -823,7 +839,10 @@ void OKeySet::executeInsert( const ORowSetRow& _rInsertRow,const ::rtl::OUString ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT "); sStmt += sMaxStmt; sStmt += ::rtl::OUString::createFromAscii("FROM "); - sStmt += m_aSelectComposedTableName; + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(m_xConnection->getMetaData(),m_sUpdateTableName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation); + sStmt += ::dbtools::composeTableNameForSelect( m_xConnection, sCatalog, sSchema, sTable ); + //sStmt += m_aSelectComposedTableName; try { // now fetch the autoincrement values diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx index ccd5cf0e6..5403a56d6 100644 --- a/dbaccess/source/core/api/KeySet.hxx +++ b/dbaccess/source/core/api/KeySet.hxx @@ -112,7 +112,6 @@ namespace dbaccess ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow> m_xRow; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer > m_xComposer; ::rtl::OUString m_sUpdateTableName; - ::rtl::OUString m_aSelectComposedTableName; ::std::vector< ::rtl::OUString > m_aFilterColumns; sal_Bool m_bRowCountFinal; |