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 #include "adabas/BKeyColumns.hxx"
27 #ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_
28 #include "adabas/BKeyColumn.hxx"
29 #endif
30 #include <com/sun/star/sdbc/XRow.hpp>
31 #include <com/sun/star/sdbc/XResultSet.hpp>
32 #include <com/sun/star/sdbc/DataType.hpp>
33 #include <com/sun/star/sdbc/ColumnValue.hpp>
34 #include "adabas/BTable.hxx"
35 
36 using namespace connectivity::adabas;
37 // -------------------------------------------------------------------------
createObject(const::rtl::OUString & _rName)38 sdbcx::ObjectType OKeyColumns::createObject(const ::rtl::OUString& _rName)
39 {
40 
41 	Reference< starsdbc::XResultSet >
42 		xResult = m_pTable->getConnection()->getMetaData()->getImportedKeys(Any(),
43 					m_pTable->getSchema(),m_pTable->getName());
44 
45 	::rtl::OUString aRefColumnName;
46 	if(xResult.is())
47 	{
48 		Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY);
49 		while(xResult->next())
50 		{
51 			if(xRow->getString(8) == _rName)
52 			{
53 				aRefColumnName = xRow->getString(4);
54 				break;
55 			}
56 		}
57 	}
58 
59 	 xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
60 		m_pTable->getSchema(),m_pTable->getName(),_rName);
61 
62 	sdbcx::ObjectType xRet = NULL;
63 	if(xResult.is())
64 	{
65 		Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY);
66 		if(xResult->next())
67 		{
68 			if(xRow->getString(4) == _rName)
69 			{
70 				OKeyColumn* pRet = new OKeyColumn(aRefColumnName,
71 													_rName,
72 													xRow->getString(6),
73 													xRow->getString(13),
74 													xRow->getInt(11),
75 													xRow->getInt(7),
76 													xRow->getInt(9),
77 													xRow->getInt(5),
78 													sal_False);
79 				xRet = pRet;
80 			}
81 		}
82 	}
83 
84 	return xRet;
85 }
86 // -------------------------------------------------------------------------
createDescriptor()87 Reference< XPropertySet > OKeyColumns::createDescriptor()
88 {
89 	OKeyColumn* pNew = new OKeyColumn();
90 	return pNew;
91 }
92 // -------------------------------------------------------------------------
93 
94