Kaydet (Commit) 0124b711 authored tarafından Ocke Janssen's avatar Ocke Janssen

check foreign key names

üst a6881c4b
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: BResultSetMetaData.cxx,v $ * $RCSfile: BResultSetMetaData.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: oj $ $Date: 2001-08-02 10:49:44 $ * last change: $Author: oj $ $Date: 2002-04-02 07:07:28 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -68,6 +68,12 @@ ...@@ -68,6 +68,12 @@
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/DataType.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_
#include <com/sun/star/sdbc/ColumnValue.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
#include <com/sun/star/sdbc/XRow.hpp>
#endif
using namespace com::sun::star::sdbc; using namespace com::sun::star::sdbc;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
...@@ -98,5 +104,29 @@ sal_Int32 SAL_CALL OAdabasResultSetMetaData::getColumnType( sal_Int32 column ) t ...@@ -98,5 +104,29 @@ sal_Int32 SAL_CALL OAdabasResultSetMetaData::getColumnType( sal_Int32 column ) t
return nType; return nType;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
sal_Int32 SAL_CALL OAdabasResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
{
// adabas return values, so we have to ask the table itself
sal_Int32 nNullable = ColumnValue::NULLABLE;
::rtl::OUString sSchema = getSchemaName( column );
::rtl::OUString sTable = getTableName( column );
::rtl::OUString sColumn = getColumnName( column );
Reference< XResultSet> xRes = m_pConnection->getMetaData()->getColumns(Any(),sSchema,sTable,sColumn);
Reference< XRow > xRow(xRes,UNO_QUERY);
if ( xRes.is() && xRow.is() )
{
sal_Int32 nType = getColumnType( column );
while ( xRes->next() )
{
if ( nType == xRow->getInt(5) )
nNullable = xRow->getInt( 11 );
}
}
else
nNullable = OAdabasResultSetMetaData_BASE::isNullable( column );
return nNullable;
}
// -----------------------------------------------------------------------------
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: BTable.cxx,v $ * $RCSfile: BTable.cxx,v $
* *
* $Revision: 1.29 $ * $Revision: 1.30 $
* *
* last change: $Author: oj $ $Date: 2002-03-21 13:40:24 $ * last change: $Author: oj $ $Date: 2002-04-02 07:07:28 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -191,12 +191,20 @@ void OAdabasTable::refreshPrimaryKeys(std::vector< ::rtl::OUString>& _rKeys) ...@@ -191,12 +191,20 @@ void OAdabasTable::refreshPrimaryKeys(std::vector< ::rtl::OUString>& _rKeys)
void OAdabasTable::refreshForgeinKeys(std::vector< ::rtl::OUString>& _rKeys) void OAdabasTable::refreshForgeinKeys(std::vector< ::rtl::OUString>& _rKeys)
{ {
Reference< XResultSet > xResult = m_pConnection->getMetaData()->getImportedKeys(Any(),m_SchemaName,m_Name); Reference< XResultSet > xResult = m_pConnection->getMetaData()->getImportedKeys(Any(),m_SchemaName,m_Name);
Reference< XRow > xRow(xResult,UNO_QUERY);
if(xResult.is()) if ( xRow.is() )
{ {
Reference< XRow > xRow(xResult,UNO_QUERY); while( xResult->next() )
while(xResult->next()) {
_rKeys.push_back(xRow->getString(12)); sal_Int32 nKeySeq = xRow->getInt(9);
if ( nKeySeq == 1 )
{ // only append when the sequnce number is 1 to forbid serveral inserting the same key name
::rtl::OUString sFkName = xRow->getString(12);
if ( !xRow->wasNull() && sFkName.getLength() )
_rKeys.push_back(sFkName);
}
}
::comphelper::disposeComponent(xResult); ::comphelper::disposeComponent(xResult);
} }
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: BResultSetMetaData.hxx,v $ * $RCSfile: BResultSetMetaData.hxx,v $
* *
* $Revision: 1.1 $ * $Revision: 1.2 $
* *
* last change: $Author: oj $ $Date: 2001-08-02 10:48:38 $ * last change: $Author: oj $ $Date: 2002-04-02 07:07:28 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -83,6 +83,7 @@ namespace connectivity ...@@ -83,6 +83,7 @@ namespace connectivity
virtual ~OAdabasResultSetMetaData(); virtual ~OAdabasResultSetMetaData();
virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
}; };
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment