1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26
27 #ifndef _CONNECTIVITY_ADABAS_BRESULTSETMETADATA_HXX_
28 #include "adabas/BResultSetMetaData.hxx"
29 #endif
30 #include "adabas/BCatalog.hxx"
31 #include <com/sun/star/sdbc/DataType.hpp>
32 #include <com/sun/star/sdbc/XRow.hpp>
33
34 using namespace com::sun::star::sdbc;
35 using namespace com::sun::star::uno;
36 using namespace connectivity::adabas;
37 using namespace connectivity;
38
OAdabasResultSetMetaData(odbc::OConnection * _pConnection,SQLHANDLE _pStmt,const::vos::ORef<OSQLColumns> & _rSelectColumns)39 OAdabasResultSetMetaData::OAdabasResultSetMetaData(odbc::OConnection* _pConnection, SQLHANDLE _pStmt,const ::vos::ORef<OSQLColumns>& _rSelectColumns )
40 : OAdabasResultSetMetaData_BASE(_pConnection,_pStmt)
41 ,m_aSelectColumns(_rSelectColumns)
42 {
43 }
44 // -------------------------------------------------------------------------
~OAdabasResultSetMetaData()45 OAdabasResultSetMetaData::~OAdabasResultSetMetaData()
46 {
47 }
48 // -----------------------------------------------------------------------------
getColumnType(sal_Int32 column)49 sal_Int32 SAL_CALL OAdabasResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
50 {
51 sal_Int32 nType = OAdabasResultSetMetaData_BASE::getColumnType( column);
52 // special handling for float values which could be doubles
53 ::rtl::OUString sTypeName;
54 OAdabasCatalog::correctColumnProperties(getPrecision(column),nType,sTypeName);
55
56 return nType;
57 }
58 // -----------------------------------------------------------------------------
isNullable(sal_Int32 column)59 sal_Int32 SAL_CALL OAdabasResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
60 {
61 sal_Int32 nValue = 0;
62 sal_Bool bFound = sal_False;
63 if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
64 bFound = (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nValue;
65
66 if ( !bFound )
67 nValue = getNumColAttrib(column,SQL_DESC_NULLABLE);
68 return nValue;
69 }
70 // -------------------------------------------------------------------------
isAutoIncrement(sal_Int32 column)71 sal_Bool SAL_CALL OAdabasResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
72 {
73 if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
74 {
75 sal_Bool bAutoIncrement = sal_False;
76 (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
77 return bAutoIncrement;
78 }
79
80 return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE;
81 }
82 // -------------------------------------------------------------------------
83
84