19b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
39b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
49b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file
59b5730f6SAndrew Rist * distributed with this work for additional information
69b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
79b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the
89b5730f6SAndrew Rist * "License"); you may not use this file except in compliance
99b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at
109b5730f6SAndrew Rist *
119b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
129b5730f6SAndrew Rist *
139b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing,
149b5730f6SAndrew Rist * software distributed under the License is distributed on an
159b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169b5730f6SAndrew Rist * KIND, either express or implied. See the License for the
179b5730f6SAndrew Rist * specific language governing permissions and limitations
189b5730f6SAndrew Rist * under the License.
199b5730f6SAndrew Rist *
209b5730f6SAndrew Rist *************************************************************/
219b5730f6SAndrew Rist
229b5730f6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "TConnection.hxx"
27cdf0e10cSrcweir
28cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_
29cdf0e10cSrcweir #include "odbc/ODatabaseMetaDataResultSet.hxx"
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/KeyRule.hpp>
33cdf0e10cSrcweir #include <com/sun/star/sdbc/ProcedureResult.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/IndexType.hpp>
35cdf0e10cSrcweir #include <comphelper/property.hxx>
36cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
37cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
38cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
39cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
40cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
41cdf0e10cSrcweir #include <comphelper/sequence.hxx>
42cdf0e10cSrcweir #include "odbc/OResultSetMetaData.hxx"
43cdf0e10cSrcweir #include "odbc/OTools.hxx"
44cdf0e10cSrcweir #include <comphelper/types.hxx>
45cdf0e10cSrcweir #include "FDatabaseMetaDataResultSetMetaData.hxx"
46cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir using namespace ::comphelper;
49cdf0e10cSrcweir
50cdf0e10cSrcweir
51cdf0e10cSrcweir using namespace connectivity::odbc;
52cdf0e10cSrcweir using namespace cppu;
53cdf0e10cSrcweir //------------------------------------------------------------------------------
54cdf0e10cSrcweir using namespace ::com::sun::star::lang;
55cdf0e10cSrcweir using namespace com::sun::star::uno;
56cdf0e10cSrcweir using namespace com::sun::star::beans;
57cdf0e10cSrcweir using namespace com::sun::star::sdbc;
58cdf0e10cSrcweir using namespace com::sun::star::util;
59cdf0e10cSrcweir
60cdf0e10cSrcweir // -------------------------------------------------------------------------
ODatabaseMetaDataResultSet(OConnection * _pConnection)61cdf0e10cSrcweir ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection)
62cdf0e10cSrcweir :ODatabaseMetaDataResultSet_BASE(m_aMutex)
63cdf0e10cSrcweir ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
64cdf0e10cSrcweir
65cdf0e10cSrcweir ,m_aStatementHandle(_pConnection->createStatementHandle())
66cdf0e10cSrcweir ,m_aStatement(NULL)
67cdf0e10cSrcweir ,m_xMetaData(NULL)
68cdf0e10cSrcweir ,m_pRowStatusArray(NULL)
69cdf0e10cSrcweir ,m_pConnection(_pConnection)
70cdf0e10cSrcweir ,m_nTextEncoding(_pConnection->getTextEncoding())
71cdf0e10cSrcweir ,m_nRowPos(-1)
72cdf0e10cSrcweir ,m_nLastColumnPos(0)
73cdf0e10cSrcweir ,m_nDriverColumnCount(0)
74cdf0e10cSrcweir ,m_nCurrentFetchState(0)
75cdf0e10cSrcweir ,m_bWasNull(sal_True)
76cdf0e10cSrcweir ,m_bEOF(sal_False)
77cdf0e10cSrcweir ,m_bFreeHandle(sal_False)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
80cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
81cdf0e10cSrcweir m_pConnection->acquire();
82cdf0e10cSrcweir m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
83cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount );
84cdf0e10cSrcweir // allocBuffer();
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir // -------------------------------------------------------------------------
~ODatabaseMetaDataResultSet()88cdf0e10cSrcweir ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
89cdf0e10cSrcweir {
90cdf0e10cSrcweir OSL_ENSURE(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed,"Object wasn't disposed!");
91cdf0e10cSrcweir if(!ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount );
94cdf0e10cSrcweir dispose();
95cdf0e10cSrcweir }
96cdf0e10cSrcweir delete [] m_pRowStatusArray;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(void)99cdf0e10cSrcweir void ODatabaseMetaDataResultSet::disposing(void)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir OPropertySetHelper::disposing();
102cdf0e10cSrcweir
103cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
104cdf0e10cSrcweir if(m_bFreeHandle)
105cdf0e10cSrcweir m_pConnection->freeStatementHandle(m_aStatementHandle);
106cdf0e10cSrcweir
107cdf0e10cSrcweir m_aStatement = NULL;
108cdf0e10cSrcweir m_xMetaData.clear();
109cdf0e10cSrcweir m_pConnection->release();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)112cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir Any aRet = OPropertySetHelper::queryInterface(rType);
115cdf0e10cSrcweir return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()118cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException)
119cdf0e10cSrcweir {
120cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
121cdf0e10cSrcweir }
122cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()123cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir ODatabaseMetaDataResultSet_BASE::acquire();
126cdf0e10cSrcweir }
127cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()128cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir ODatabaseMetaDataResultSet_BASE::release();
131cdf0e10cSrcweir }
132cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()133cdf0e10cSrcweir Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
136cdf0e10cSrcweir ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
137cdf0e10cSrcweir ::getCppuType( (const Reference< XPropertySet > *)0 ));
138cdf0e10cSrcweir
139cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
140cdf0e10cSrcweir }
141cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapColumn(sal_Int32 column)142cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir sal_Int32 map = column;
145cdf0e10cSrcweir
146cdf0e10cSrcweir if (!m_aColMapping.empty())
147cdf0e10cSrcweir {
148cdf0e10cSrcweir // Validate column number
149cdf0e10cSrcweir map = m_aColMapping[column];
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir return map;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // -------------------------------------------------------------------------
155cdf0e10cSrcweir
findColumn(const::rtl::OUString & columnName)156cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
157cdf0e10cSrcweir {
158cdf0e10cSrcweir
159cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
160cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
161cdf0e10cSrcweir
162cdf0e10cSrcweir
163cdf0e10cSrcweir Reference< XResultSetMetaData > xMeta = getMetaData();
164cdf0e10cSrcweir sal_Int32 nLen = xMeta->getColumnCount();
165cdf0e10cSrcweir sal_Int32 i = 1;
166cdf0e10cSrcweir for(;i<=nLen;++i)
167cdf0e10cSrcweir if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
168cdf0e10cSrcweir columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
169cdf0e10cSrcweir break;
170cdf0e10cSrcweir return i;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir // -------------------------------------------------------------------------
getBinaryStream(sal_Int32)173cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
176cdf0e10cSrcweir return NULL;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)179cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getCharacterStream", *this );
182cdf0e10cSrcweir return NULL;
183cdf0e10cSrcweir }
184cdf0e10cSrcweir
185cdf0e10cSrcweir // -------------------------------------------------------------------------
getBoolean(sal_Int32 columnIndex)186cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir
189cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
190cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
191cdf0e10cSrcweir
192cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
193cdf0e10cSrcweir
194cdf0e10cSrcweir sal_Bool bRet = sal_False;
195cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
198cdf0e10cSrcweir switch(nType)
199cdf0e10cSrcweir {
200cdf0e10cSrcweir case DataType::BIT:
201cdf0e10cSrcweir {
202cdf0e10cSrcweir sal_Int8 nValue = 0;
203cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
204cdf0e10cSrcweir bRet = nValue != 0;
205cdf0e10cSrcweir }
206cdf0e10cSrcweir break;
207cdf0e10cSrcweir default:
208cdf0e10cSrcweir bRet = getInt(columnIndex) != 0;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir }
211cdf0e10cSrcweir return bRet;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir // -------------------------------------------------------------------------
214cdf0e10cSrcweir
getByte(sal_Int32 columnIndex)215cdf0e10cSrcweir sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir
218cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
219cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
220cdf0e10cSrcweir
221cdf0e10cSrcweir
222cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
223cdf0e10cSrcweir sal_Int8 nVal = 0;
224cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_TINYINT,m_bWasNull,**this,&nVal,sizeof nVal);
227cdf0e10cSrcweir
228cdf0e10cSrcweir ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
229cdf0e10cSrcweir if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
230cdf0e10cSrcweir return sal_Int8((*aValueRangeIter).second[(sal_Int32)nVal]);
231cdf0e10cSrcweir }
232cdf0e10cSrcweir else
233cdf0e10cSrcweir m_bWasNull = sal_True;
234cdf0e10cSrcweir return nVal;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir // -------------------------------------------------------------------------
237cdf0e10cSrcweir
getBytes(sal_Int32 columnIndex)238cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir
241cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
242cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
243cdf0e10cSrcweir
244cdf0e10cSrcweir
245cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
246cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
249cdf0e10cSrcweir switch(nType)
250cdf0e10cSrcweir {
251cdf0e10cSrcweir case DataType::VARCHAR:
252cdf0e10cSrcweir case DataType::LONGVARCHAR:
253cdf0e10cSrcweir {
254cdf0e10cSrcweir ::rtl::OUString aRet = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
255cdf0e10cSrcweir return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
256cdf0e10cSrcweir }
257cdf0e10cSrcweir }
258cdf0e10cSrcweir return OTools::getBytesValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
259cdf0e10cSrcweir }
260cdf0e10cSrcweir else
261cdf0e10cSrcweir m_bWasNull = sal_True;
262cdf0e10cSrcweir return Sequence<sal_Int8>();
263cdf0e10cSrcweir }
264cdf0e10cSrcweir // -------------------------------------------------------------------------
265cdf0e10cSrcweir
getDate(sal_Int32 columnIndex)266cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
269cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
270cdf0e10cSrcweir
271cdf0e10cSrcweir
272cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
273cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir DATE_STRUCT aDate;
276cdf0e10cSrcweir aDate.day = 0;
277cdf0e10cSrcweir aDate.month = 0;
278cdf0e10cSrcweir aDate.year = 0;
279cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
280cdf0e10cSrcweir return Date(aDate.day,aDate.month,aDate.year);
281cdf0e10cSrcweir }
282cdf0e10cSrcweir else
283cdf0e10cSrcweir m_bWasNull = sal_True;
284cdf0e10cSrcweir return Date();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir // -------------------------------------------------------------------------
287cdf0e10cSrcweir
getDouble(sal_Int32 columnIndex)288cdf0e10cSrcweir double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
289cdf0e10cSrcweir {
290cdf0e10cSrcweir
291cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
292cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
293cdf0e10cSrcweir
294cdf0e10cSrcweir
295cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
296cdf0e10cSrcweir double nValue(0.0);
297cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
298cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
299cdf0e10cSrcweir else
300cdf0e10cSrcweir m_bWasNull = sal_True;
301cdf0e10cSrcweir return nValue;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir // -------------------------------------------------------------------------
304cdf0e10cSrcweir
getFloat(sal_Int32 columnIndex)305cdf0e10cSrcweir float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir
308cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
309cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
310cdf0e10cSrcweir
311cdf0e10cSrcweir
312cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
313cdf0e10cSrcweir float nVal(0);
314cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
315cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
316cdf0e10cSrcweir else
317cdf0e10cSrcweir m_bWasNull = sal_True;
318cdf0e10cSrcweir return nVal;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir // -------------------------------------------------------------------------
321cdf0e10cSrcweir
getInt(sal_Int32 columnIndex)322cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir
325cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
326cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
327cdf0e10cSrcweir
328cdf0e10cSrcweir
329cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
330cdf0e10cSrcweir sal_Int32 nVal = 0;
331cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_LONG,m_bWasNull,**this,&nVal,sizeof nVal);
334cdf0e10cSrcweir
335cdf0e10cSrcweir ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
336cdf0e10cSrcweir if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
337cdf0e10cSrcweir return (*aValueRangeIter).second[(sal_Int32)nVal];
338cdf0e10cSrcweir }
339cdf0e10cSrcweir else
340cdf0e10cSrcweir m_bWasNull = sal_True;
341cdf0e10cSrcweir return nVal;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir // -------------------------------------------------------------------------
344cdf0e10cSrcweir
getRow()345cdf0e10cSrcweir sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir return 0;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir // -------------------------------------------------------------------------
350cdf0e10cSrcweir
getLong(sal_Int32)351cdf0e10cSrcweir sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
352cdf0e10cSrcweir {
353cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getLong", *this );
354cdf0e10cSrcweir return 0;
355cdf0e10cSrcweir }
356cdf0e10cSrcweir // -------------------------------------------------------------------------
357cdf0e10cSrcweir
getMetaData()358cdf0e10cSrcweir Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException)
359cdf0e10cSrcweir {
360cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
361cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
362cdf0e10cSrcweir return m_xMetaData.is() ? m_xMetaData : (m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle));
363cdf0e10cSrcweir }
364cdf0e10cSrcweir // -------------------------------------------------------------------------
getArray(sal_Int32)365cdf0e10cSrcweir Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
368cdf0e10cSrcweir return NULL;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir // -------------------------------------------------------------------------
getClob(sal_Int32)371cdf0e10cSrcweir Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
374cdf0e10cSrcweir return NULL;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir // -------------------------------------------------------------------------
getBlob(sal_Int32)377cdf0e10cSrcweir Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
380cdf0e10cSrcweir return NULL;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir // -------------------------------------------------------------------------
383cdf0e10cSrcweir
getRef(sal_Int32)384cdf0e10cSrcweir Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
387cdf0e10cSrcweir return NULL;
388cdf0e10cSrcweir }
389cdf0e10cSrcweir // -------------------------------------------------------------------------
390cdf0e10cSrcweir
getObject(sal_Int32,const Reference<::com::sun::star::container::XNameAccess> &)391cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this );
394cdf0e10cSrcweir return Any();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir // -------------------------------------------------------------------------
397cdf0e10cSrcweir
getShort(sal_Int32 columnIndex)398cdf0e10cSrcweir sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir
401cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
402cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
403cdf0e10cSrcweir
404cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
405cdf0e10cSrcweir sal_Int16 nVal = 0;
406cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_SHORT,m_bWasNull,**this,&nVal,sizeof nVal);
409cdf0e10cSrcweir
410cdf0e10cSrcweir ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
411cdf0e10cSrcweir if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
412cdf0e10cSrcweir return sal_Int16((*aValueRangeIter).second[(sal_Int32)nVal]);
413cdf0e10cSrcweir }
414cdf0e10cSrcweir else
415cdf0e10cSrcweir m_bWasNull = sal_True;
416cdf0e10cSrcweir return nVal;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir // -------------------------------------------------------------------------
419cdf0e10cSrcweir
getString(sal_Int32 columnIndex)420cdf0e10cSrcweir ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
421cdf0e10cSrcweir {
422cdf0e10cSrcweir
423cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
424cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
425cdf0e10cSrcweir
426cdf0e10cSrcweir
427cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
428cdf0e10cSrcweir ::rtl::OUString aVal;
429cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
430cdf0e10cSrcweir aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
431cdf0e10cSrcweir else
432cdf0e10cSrcweir m_bWasNull = sal_True;
433cdf0e10cSrcweir
434cdf0e10cSrcweir return aVal;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir
437cdf0e10cSrcweir // -------------------------------------------------------------------------
438cdf0e10cSrcweir
439cdf0e10cSrcweir
getTime(sal_Int32 columnIndex)440cdf0e10cSrcweir ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir
443cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
444cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
445cdf0e10cSrcweir
446cdf0e10cSrcweir
447cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
448cdf0e10cSrcweir TIME_STRUCT aTime={0,0,0};
449cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
450cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
451cdf0e10cSrcweir else
452cdf0e10cSrcweir m_bWasNull = sal_True;
453cdf0e10cSrcweir return Time(0,aTime.second,aTime.minute,aTime.hour);
454cdf0e10cSrcweir }
455cdf0e10cSrcweir // -------------------------------------------------------------------------
456cdf0e10cSrcweir
457cdf0e10cSrcweir
getTimestamp(sal_Int32 columnIndex)458cdf0e10cSrcweir ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir
461cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
462cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
463cdf0e10cSrcweir
464cdf0e10cSrcweir
465cdf0e10cSrcweir columnIndex = mapColumn(columnIndex);
466cdf0e10cSrcweir TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
467cdf0e10cSrcweir if(columnIndex <= m_nDriverColumnCount)
468cdf0e10cSrcweir OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime);
469cdf0e10cSrcweir else
470cdf0e10cSrcweir m_bWasNull = sal_True;
471cdf0e10cSrcweir return DateTime((sal_uInt16)aTime.fraction*1000,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year);
472cdf0e10cSrcweir }
473cdf0e10cSrcweir // -------------------------------------------------------------------------
474cdf0e10cSrcweir
isAfterLast()475cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir
478cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
479cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
480cdf0e10cSrcweir
481cdf0e10cSrcweir
482cdf0e10cSrcweir return m_nCurrentFetchState == SQL_NO_DATA;
483cdf0e10cSrcweir }
484cdf0e10cSrcweir // -------------------------------------------------------------------------
isFirst()485cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
486cdf0e10cSrcweir {
487cdf0e10cSrcweir
488cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
489cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
490cdf0e10cSrcweir
491cdf0e10cSrcweir
492cdf0e10cSrcweir return m_nRowPos == 1;
493cdf0e10cSrcweir }
494cdf0e10cSrcweir // -------------------------------------------------------------------------
isLast()495cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
496cdf0e10cSrcweir {
497cdf0e10cSrcweir
498cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
499cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
500cdf0e10cSrcweir
501cdf0e10cSrcweir
502cdf0e10cSrcweir return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
503cdf0e10cSrcweir }
504cdf0e10cSrcweir // -------------------------------------------------------------------------
beforeFirst()505cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir
508cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
509cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
510cdf0e10cSrcweir
511cdf0e10cSrcweir
512cdf0e10cSrcweir if(first())
513cdf0e10cSrcweir previous();
514cdf0e10cSrcweir m_nCurrentFetchState = SQL_SUCCESS;
515cdf0e10cSrcweir }
516cdf0e10cSrcweir // -------------------------------------------------------------------------
afterLast()517cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException)
518cdf0e10cSrcweir {
519cdf0e10cSrcweir
520cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
521cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
522cdf0e10cSrcweir
523cdf0e10cSrcweir
524cdf0e10cSrcweir if(last())
525cdf0e10cSrcweir next();
526cdf0e10cSrcweir m_bEOF = sal_True;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir // -------------------------------------------------------------------------
529cdf0e10cSrcweir
close()530cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir {
533cdf0e10cSrcweir
534cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
535cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
536cdf0e10cSrcweir
537cdf0e10cSrcweir }
538cdf0e10cSrcweir dispose();
539cdf0e10cSrcweir }
540cdf0e10cSrcweir // -------------------------------------------------------------------------
541cdf0e10cSrcweir
first()542cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException)
543cdf0e10cSrcweir {
544cdf0e10cSrcweir
545cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
546cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
547cdf0e10cSrcweir
548cdf0e10cSrcweir
549cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
550cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
551cdf0e10cSrcweir sal_Bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
552cdf0e10cSrcweir if( bRet )
553cdf0e10cSrcweir m_nRowPos = 1;
554cdf0e10cSrcweir return bRet;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir // -------------------------------------------------------------------------
557cdf0e10cSrcweir
last()558cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
561cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
562cdf0e10cSrcweir
563cdf0e10cSrcweir
564cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
565cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
566cdf0e10cSrcweir // here I know definitely that I stand on the last record
567cdf0e10cSrcweir return (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO);
568cdf0e10cSrcweir }
569cdf0e10cSrcweir // -------------------------------------------------------------------------
absolute(sal_Int32 row)570cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
571cdf0e10cSrcweir {
572cdf0e10cSrcweir
573cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
574cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
575cdf0e10cSrcweir
576cdf0e10cSrcweir
577cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
578cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
579cdf0e10cSrcweir sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
580cdf0e10cSrcweir if(bRet)
581cdf0e10cSrcweir m_nRowPos = row;
582cdf0e10cSrcweir return bRet;
583cdf0e10cSrcweir }
584cdf0e10cSrcweir // -------------------------------------------------------------------------
relative(sal_Int32 row)585cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
586cdf0e10cSrcweir {
587cdf0e10cSrcweir
588cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
589cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
590cdf0e10cSrcweir
591cdf0e10cSrcweir
592cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
593cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
594cdf0e10cSrcweir sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
595cdf0e10cSrcweir if(bRet)
596cdf0e10cSrcweir m_nRowPos += row;
597cdf0e10cSrcweir return bRet;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir // -------------------------------------------------------------------------
previous()600cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
601cdf0e10cSrcweir {
602cdf0e10cSrcweir
603cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
604cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
605cdf0e10cSrcweir
606cdf0e10cSrcweir
607cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
608cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
609cdf0e10cSrcweir sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
610cdf0e10cSrcweir if(bRet)
611cdf0e10cSrcweir --m_nRowPos;
612cdf0e10cSrcweir return bRet;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir // -------------------------------------------------------------------------
getStatement()615cdf0e10cSrcweir Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
616cdf0e10cSrcweir {
617cdf0e10cSrcweir return NULL;
618cdf0e10cSrcweir }
619cdf0e10cSrcweir // -------------------------------------------------------------------------
620cdf0e10cSrcweir
rowDeleted()621cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
622cdf0e10cSrcweir {
623cdf0e10cSrcweir
624cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
625cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
626cdf0e10cSrcweir
627cdf0e10cSrcweir
628cdf0e10cSrcweir return m_pRowStatusArray[0] == SQL_ROW_DELETED;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir // -------------------------------------------------------------------------
rowInserted()631cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
632cdf0e10cSrcweir {
633cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
634cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
635cdf0e10cSrcweir
636cdf0e10cSrcweir
637cdf0e10cSrcweir return m_pRowStatusArray[0] == SQL_ROW_ADDED;
638cdf0e10cSrcweir }
639cdf0e10cSrcweir // -------------------------------------------------------------------------
rowUpdated()640cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
641cdf0e10cSrcweir {
642cdf0e10cSrcweir
643cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
644cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
645cdf0e10cSrcweir
646cdf0e10cSrcweir
647cdf0e10cSrcweir return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
648cdf0e10cSrcweir }
649cdf0e10cSrcweir // -------------------------------------------------------------------------
650cdf0e10cSrcweir
isBeforeFirst()651cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir
654cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
655cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
656cdf0e10cSrcweir
657cdf0e10cSrcweir
658cdf0e10cSrcweir return m_nRowPos == 0;
659cdf0e10cSrcweir }
660cdf0e10cSrcweir // -------------------------------------------------------------------------
661cdf0e10cSrcweir
next()662cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException)
663cdf0e10cSrcweir {
664cdf0e10cSrcweir
665cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
666cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
667cdf0e10cSrcweir
668cdf0e10cSrcweir
669cdf0e10cSrcweir // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
670cdf0e10cSrcweir m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
671cdf0e10cSrcweir OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
672cdf0e10cSrcweir return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
673cdf0e10cSrcweir }
674cdf0e10cSrcweir // -------------------------------------------------------------------------
675cdf0e10cSrcweir
wasNull()676cdf0e10cSrcweir sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException)
677cdf0e10cSrcweir {
678cdf0e10cSrcweir
679cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
680cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
681cdf0e10cSrcweir
682cdf0e10cSrcweir
683cdf0e10cSrcweir return m_bWasNull;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshRow()686cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException)
687cdf0e10cSrcweir {
688cdf0e10cSrcweir
689cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
690cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
691cdf0e10cSrcweir
692cdf0e10cSrcweir }
693cdf0e10cSrcweir // -------------------------------------------------------------------------
694cdf0e10cSrcweir
cancel()695cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException)
696cdf0e10cSrcweir {
697cdf0e10cSrcweir
698cdf0e10cSrcweir checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
699cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex );
700cdf0e10cSrcweir
701cdf0e10cSrcweir
702cdf0e10cSrcweir OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
703cdf0e10cSrcweir }
704cdf0e10cSrcweir // -------------------------------------------------------------------------
clearWarnings()705cdf0e10cSrcweir void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
706cdf0e10cSrcweir {
707cdf0e10cSrcweir }
708cdf0e10cSrcweir // -------------------------------------------------------------------------
getWarnings()709cdf0e10cSrcweir Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir return Any();
712cdf0e10cSrcweir }
713cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetConcurrency() const714cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const throw(SQLException, RuntimeException)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir return ResultSetConcurrency::READ_ONLY;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetType() const719cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const throw(SQLException, RuntimeException)
720cdf0e10cSrcweir {
721cdf0e10cSrcweir return ResultSetType::FORWARD_ONLY;
722cdf0e10cSrcweir }
723cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchDirection() const724cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const throw(SQLException, RuntimeException)
725cdf0e10cSrcweir {
726cdf0e10cSrcweir return FetchDirection::FORWARD;
727cdf0e10cSrcweir }
728cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchSize() const729cdf0e10cSrcweir sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const throw(SQLException, RuntimeException)
730cdf0e10cSrcweir {
731cdf0e10cSrcweir sal_Int32 nValue=1;
732cdf0e10cSrcweir return nValue;
733cdf0e10cSrcweir }
734cdf0e10cSrcweir //------------------------------------------------------------------------------
getCursorName() const735cdf0e10cSrcweir ::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const throw(SQLException, RuntimeException)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir return ::rtl::OUString();
738cdf0e10cSrcweir }
739cdf0e10cSrcweir
740cdf0e10cSrcweir // -------------------------------------------------------------------------
createArrayHelper() const741cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
742cdf0e10cSrcweir {
743cdf0e10cSrcweir
744cdf0e10cSrcweir Sequence< com::sun::star::beans::Property > aProps(5);
745cdf0e10cSrcweir com::sun::star::beans::Property* pProperties = aProps.getArray();
746cdf0e10cSrcweir sal_Int32 nPos = 0;
747cdf0e10cSrcweir DECL_PROP0(CURSORNAME, ::rtl::OUString);
748cdf0e10cSrcweir DECL_PROP0(FETCHDIRECTION, sal_Int32);
749cdf0e10cSrcweir DECL_PROP0(FETCHSIZE, sal_Int32);
750cdf0e10cSrcweir DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
751cdf0e10cSrcweir DECL_PROP0(RESULTSETTYPE, sal_Int32);
752cdf0e10cSrcweir
753cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps);
754cdf0e10cSrcweir }
755cdf0e10cSrcweir // -------------------------------------------------------------------------
getInfoHelper()756cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
757cdf0e10cSrcweir {
758cdf0e10cSrcweir return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
759cdf0e10cSrcweir }
760cdf0e10cSrcweir // -------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)761cdf0e10cSrcweir sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
762cdf0e10cSrcweir Any & rConvertedValue,
763cdf0e10cSrcweir Any & rOldValue,
764cdf0e10cSrcweir sal_Int32 nHandle,
765cdf0e10cSrcweir const Any& rValue )
766cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir switch(nHandle)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME:
771cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY:
772cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE:
773cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException();
774cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION:
775cdf0e10cSrcweir return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
776cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE:
777cdf0e10cSrcweir return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
778cdf0e10cSrcweir default:
779cdf0e10cSrcweir ;
780cdf0e10cSrcweir }
781cdf0e10cSrcweir return sal_False;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any &)784cdf0e10cSrcweir void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& /*rValue*/ ) throw (Exception)
785cdf0e10cSrcweir {
786cdf0e10cSrcweir switch(nHandle)
787cdf0e10cSrcweir {
788cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME:
789cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY:
790cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE:
791cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION:
792cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE:
793cdf0e10cSrcweir throw Exception();
794cdf0e10cSrcweir default:
795cdf0e10cSrcweir OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!");
796cdf0e10cSrcweir }
797cdf0e10cSrcweir }
798cdf0e10cSrcweir // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const799cdf0e10cSrcweir void ODatabaseMetaDataResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
800cdf0e10cSrcweir {
801cdf0e10cSrcweir switch(nHandle)
802cdf0e10cSrcweir {
803cdf0e10cSrcweir case PROPERTY_ID_CURSORNAME:
804cdf0e10cSrcweir rValue <<= getCursorName();
805cdf0e10cSrcweir break;
806cdf0e10cSrcweir case PROPERTY_ID_RESULTSETCONCURRENCY:
807cdf0e10cSrcweir rValue <<= getResultSetConcurrency();
808cdf0e10cSrcweir break;
809cdf0e10cSrcweir case PROPERTY_ID_RESULTSETTYPE:
810cdf0e10cSrcweir rValue <<= getResultSetType();
811cdf0e10cSrcweir break;
812cdf0e10cSrcweir case PROPERTY_ID_FETCHDIRECTION:
813cdf0e10cSrcweir rValue <<= getFetchDirection();
814cdf0e10cSrcweir break;
815cdf0e10cSrcweir case PROPERTY_ID_FETCHSIZE:
816cdf0e10cSrcweir rValue <<= getFetchSize();
817cdf0e10cSrcweir break;
818cdf0e10cSrcweir }
819cdf0e10cSrcweir }
820cdf0e10cSrcweir // -------------------------------------------------------------------------
openTypeInfo()821cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openTypeInfo() throw(SQLException, RuntimeException)
822cdf0e10cSrcweir {
823cdf0e10cSrcweir TInt2IntMap aMap;
824cdf0e10cSrcweir aMap[SQL_BIT] = DataType::BIT;
825cdf0e10cSrcweir aMap[SQL_TINYINT] = DataType::TINYINT;
826cdf0e10cSrcweir aMap[SQL_SMALLINT] = DataType::SMALLINT;
827cdf0e10cSrcweir aMap[SQL_INTEGER] = DataType::INTEGER;
828cdf0e10cSrcweir aMap[SQL_FLOAT] = DataType::FLOAT;
829cdf0e10cSrcweir aMap[SQL_REAL] = DataType::REAL;
830cdf0e10cSrcweir aMap[SQL_DOUBLE] = DataType::DOUBLE;
831cdf0e10cSrcweir aMap[SQL_BIGINT] = DataType::BIGINT;
832cdf0e10cSrcweir
833cdf0e10cSrcweir aMap[SQL_CHAR] = DataType::CHAR;
834cdf0e10cSrcweir aMap[SQL_WCHAR] = DataType::CHAR;
835cdf0e10cSrcweir aMap[SQL_VARCHAR] = DataType::VARCHAR;
836cdf0e10cSrcweir aMap[SQL_WVARCHAR] = DataType::VARCHAR;
837cdf0e10cSrcweir aMap[SQL_LONGVARCHAR] = DataType::LONGVARCHAR;
838cdf0e10cSrcweir aMap[SQL_WLONGVARCHAR] = DataType::LONGVARCHAR;
839cdf0e10cSrcweir
840cdf0e10cSrcweir aMap[SQL_TYPE_DATE] = DataType::DATE;
841cdf0e10cSrcweir aMap[SQL_DATE] = DataType::DATE;
842cdf0e10cSrcweir aMap[SQL_TYPE_TIME] = DataType::TIME;
843cdf0e10cSrcweir aMap[SQL_TIME] = DataType::TIME;
844cdf0e10cSrcweir aMap[SQL_TYPE_TIMESTAMP] = DataType::TIMESTAMP;
845cdf0e10cSrcweir aMap[SQL_TIMESTAMP] = DataType::TIMESTAMP;
846cdf0e10cSrcweir
847cdf0e10cSrcweir aMap[SQL_DECIMAL] = DataType::DECIMAL;
848cdf0e10cSrcweir aMap[SQL_NUMERIC] = DataType::NUMERIC;
849cdf0e10cSrcweir
850cdf0e10cSrcweir aMap[SQL_BINARY] = DataType::BINARY;
851cdf0e10cSrcweir aMap[SQL_VARBINARY] = DataType::VARBINARY;
852cdf0e10cSrcweir aMap[SQL_LONGVARBINARY] = DataType::LONGVARBINARY;
853cdf0e10cSrcweir
854cdf0e10cSrcweir aMap[SQL_GUID] = DataType::VARBINARY;
855cdf0e10cSrcweir
856cdf0e10cSrcweir
857cdf0e10cSrcweir m_aValueRange[2] = aMap;
858cdf0e10cSrcweir
859cdf0e10cSrcweir OTools::ThrowException(m_pConnection,N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
860cdf0e10cSrcweir checkColumnCount();
861cdf0e10cSrcweir }
862cdf0e10cSrcweir //-----------------------------------------------------------------------------
openTables(const Any & catalog,const::rtl::OUString & schemaPattern,const::rtl::OUString & tableNamePattern,const Sequence<::rtl::OUString> & types)863cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUString& schemaPattern,
864cdf0e10cSrcweir const ::rtl::OUString& tableNamePattern,
865cdf0e10cSrcweir const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
866cdf0e10cSrcweir {
867cdf0e10cSrcweir m_bFreeHandle = sal_True;
868cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
869cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
870cdf0e10cSrcweir
871cdf0e10cSrcweir if(schemaPattern.toChar() != '%')
872cdf0e10cSrcweir pSchemaPat = &schemaPattern;
873cdf0e10cSrcweir else
874cdf0e10cSrcweir pSchemaPat = NULL;
875cdf0e10cSrcweir
876cdf0e10cSrcweir if ( catalog.hasValue() )
877cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
878cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
879cdf0e10cSrcweir
880cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
881cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
882*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr();
883cdf0e10cSrcweir
884cdf0e10cSrcweir
885cdf0e10cSrcweir const char *pCOL = NULL;
886cdf0e10cSrcweir const char* pComma = ",";
887cdf0e10cSrcweir const ::rtl::OUString* pBegin = types.getConstArray();
888cdf0e10cSrcweir const ::rtl::OUString* pEnd = pBegin + types.getLength();
889cdf0e10cSrcweir for(;pBegin != pEnd;++pBegin)
890cdf0e10cSrcweir {
891cdf0e10cSrcweir aCOL += ::rtl::OUStringToOString(*pBegin,m_nTextEncoding);
892cdf0e10cSrcweir aCOL += pComma;
893cdf0e10cSrcweir }
894cdf0e10cSrcweir if ( aCOL.getLength() )
895cdf0e10cSrcweir {
896cdf0e10cSrcweir aCOL = aCOL.replaceAt(aCOL.getLength()-1,1,pComma);
897cdf0e10cSrcweir pCOL = aCOL.getStr();
898cdf0e10cSrcweir }
899cdf0e10cSrcweir else
900cdf0e10cSrcweir pCOL = SQL_ALL_TABLE_TYPES;
901cdf0e10cSrcweir
902cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
903cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
904cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
905cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
906cdf0e10cSrcweir (SDB_ODBC_CHAR *) pCOL, pCOL ? SQL_NTS : 0);
907cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
908cdf0e10cSrcweir checkColumnCount();
909cdf0e10cSrcweir
910cdf0e10cSrcweir }
911cdf0e10cSrcweir //-----------------------------------------------------------------------------
openTablesTypes()912cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
913cdf0e10cSrcweir {
914cdf0e10cSrcweir m_bFreeHandle = sal_True;
915cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
916cdf0e10cSrcweir 0,0,
917cdf0e10cSrcweir 0,0,
918cdf0e10cSrcweir 0,0,
919cdf0e10cSrcweir (SDB_ODBC_CHAR *) SQL_ALL_TABLE_TYPES,SQL_NTS);
920cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
921cdf0e10cSrcweir
922cdf0e10cSrcweir m_aColMapping.clear();
923cdf0e10cSrcweir m_aColMapping.push_back(-1);
924cdf0e10cSrcweir m_aColMapping.push_back(4);
925cdf0e10cSrcweir m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
926cdf0e10cSrcweir checkColumnCount();
927cdf0e10cSrcweir }
928cdf0e10cSrcweir // -------------------------------------------------------------------------
openCatalogs()929cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
930cdf0e10cSrcweir {
931cdf0e10cSrcweir m_bFreeHandle = sal_True;
932cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
933cdf0e10cSrcweir (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
934cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS,
935cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS,
936cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS);
937cdf0e10cSrcweir
938cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
939cdf0e10cSrcweir
940cdf0e10cSrcweir m_aColMapping.clear();
941cdf0e10cSrcweir m_aColMapping.push_back(-1);
942cdf0e10cSrcweir m_aColMapping.push_back(1);
943cdf0e10cSrcweir m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
944cdf0e10cSrcweir checkColumnCount();
945cdf0e10cSrcweir }
946cdf0e10cSrcweir // -------------------------------------------------------------------------
openSchemas()947cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir m_bFreeHandle = sal_True;
950cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
951cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS,
952cdf0e10cSrcweir (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
953cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS,
954cdf0e10cSrcweir (SDB_ODBC_CHAR *) "",SQL_NTS);
955cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
956cdf0e10cSrcweir
957cdf0e10cSrcweir m_aColMapping.clear();
958cdf0e10cSrcweir m_aColMapping.push_back(-1);
959cdf0e10cSrcweir m_aColMapping.push_back(2);
960cdf0e10cSrcweir m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
961cdf0e10cSrcweir checkColumnCount();
962cdf0e10cSrcweir }
963cdf0e10cSrcweir // -------------------------------------------------------------------------
openColumnPrivileges(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table,const::rtl::OUString & columnNamePattern)964cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, const ::rtl::OUString& schema,
965cdf0e10cSrcweir const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern )
966cdf0e10cSrcweir throw(SQLException, RuntimeException)
967cdf0e10cSrcweir {
968cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
969cdf0e10cSrcweir
970cdf0e10cSrcweir if(schema.toChar() != '%')
971cdf0e10cSrcweir pSchemaPat = &schema;
972cdf0e10cSrcweir else
973cdf0e10cSrcweir pSchemaPat = NULL;
974cdf0e10cSrcweir
975cdf0e10cSrcweir m_bFreeHandle = sal_True;
976cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
977cdf0e10cSrcweir
978cdf0e10cSrcweir if ( catalog.hasValue() )
979cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
980cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
981cdf0e10cSrcweir
982cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
983cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
984*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr(),
985*24c56ab9SHerbert Dürr *pCOL = (aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding)).getStr();
986cdf0e10cSrcweir
987cdf0e10cSrcweir
988cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle,
989cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
990cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
991cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
992cdf0e10cSrcweir (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
993cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
994cdf0e10cSrcweir
995cdf0e10cSrcweir checkColumnCount();
996cdf0e10cSrcweir }
997cdf0e10cSrcweir // -------------------------------------------------------------------------
openColumns(const Any & catalog,const::rtl::OUString & schemaPattern,const::rtl::OUString & tableNamePattern,const::rtl::OUString & columnNamePattern)998cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openColumns( const Any& catalog, const ::rtl::OUString& schemaPattern,
999cdf0e10cSrcweir const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern )
1000cdf0e10cSrcweir throw(SQLException, RuntimeException)
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir if(schemaPattern.toChar() != '%')
1005cdf0e10cSrcweir pSchemaPat = &schemaPattern;
1006cdf0e10cSrcweir else
1007cdf0e10cSrcweir pSchemaPat = NULL;
1008cdf0e10cSrcweir
1009cdf0e10cSrcweir m_bFreeHandle = sal_True;
1010cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
1011cdf0e10cSrcweir if ( catalog.hasValue() )
1012cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1013cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1016cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1017*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr(),
1018*24c56ab9SHerbert Dürr *pCOL = (aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding)).getStr();
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir
1021cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle,
1022cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1023cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
1024cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
1025cdf0e10cSrcweir (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
1026cdf0e10cSrcweir
1027cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1028cdf0e10cSrcweir TInt2IntMap aMap;
1029cdf0e10cSrcweir aMap[SQL_BIT] = DataType::BIT;
1030cdf0e10cSrcweir aMap[SQL_TINYINT] = DataType::TINYINT;
1031cdf0e10cSrcweir aMap[SQL_SMALLINT] = DataType::SMALLINT;
1032cdf0e10cSrcweir aMap[SQL_INTEGER] = DataType::INTEGER;
1033cdf0e10cSrcweir aMap[SQL_FLOAT] = DataType::FLOAT;
1034cdf0e10cSrcweir aMap[SQL_REAL] = DataType::REAL;
1035cdf0e10cSrcweir aMap[SQL_DOUBLE] = DataType::DOUBLE;
1036cdf0e10cSrcweir aMap[SQL_BIGINT] = DataType::BIGINT;
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir aMap[SQL_CHAR] = DataType::CHAR;
1039cdf0e10cSrcweir aMap[SQL_WCHAR] = DataType::CHAR;
1040cdf0e10cSrcweir aMap[SQL_VARCHAR] = DataType::VARCHAR;
1041cdf0e10cSrcweir aMap[SQL_WVARCHAR] = DataType::VARCHAR;
1042cdf0e10cSrcweir aMap[SQL_LONGVARCHAR] = DataType::LONGVARCHAR;
1043cdf0e10cSrcweir aMap[SQL_WLONGVARCHAR] = DataType::LONGVARCHAR;
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir aMap[SQL_TYPE_DATE] = DataType::DATE;
1046cdf0e10cSrcweir aMap[SQL_DATE] = DataType::DATE;
1047cdf0e10cSrcweir aMap[SQL_TYPE_TIME] = DataType::TIME;
1048cdf0e10cSrcweir aMap[SQL_TIME] = DataType::TIME;
1049cdf0e10cSrcweir aMap[SQL_TYPE_TIMESTAMP] = DataType::TIMESTAMP;
1050cdf0e10cSrcweir aMap[SQL_TIMESTAMP] = DataType::TIMESTAMP;
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir aMap[SQL_DECIMAL] = DataType::DECIMAL;
1053cdf0e10cSrcweir aMap[SQL_NUMERIC] = DataType::NUMERIC;
1054cdf0e10cSrcweir
1055cdf0e10cSrcweir aMap[SQL_BINARY] = DataType::BINARY;
1056cdf0e10cSrcweir aMap[SQL_VARBINARY] = DataType::VARBINARY;
1057cdf0e10cSrcweir aMap[SQL_LONGVARBINARY] = DataType::LONGVARBINARY;
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir aMap[SQL_GUID] = DataType::VARBINARY;
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir m_aValueRange[5] = aMap;
1062cdf0e10cSrcweir checkColumnCount();
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir // -------------------------------------------------------------------------
openProcedureColumns(const Any & catalog,const::rtl::OUString & schemaPattern,const::rtl::OUString & procedureNamePattern,const::rtl::OUString & columnNamePattern)1065cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog, const ::rtl::OUString& schemaPattern,
1066cdf0e10cSrcweir const ::rtl::OUString& procedureNamePattern,const ::rtl::OUString& columnNamePattern )
1067cdf0e10cSrcweir throw(SQLException, RuntimeException)
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1070cdf0e10cSrcweir
1071cdf0e10cSrcweir if(schemaPattern.toChar() != '%')
1072cdf0e10cSrcweir pSchemaPat = &schemaPattern;
1073cdf0e10cSrcweir else
1074cdf0e10cSrcweir pSchemaPat = NULL;
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir m_bFreeHandle = sal_True;
1077cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
1078cdf0e10cSrcweir if ( catalog.hasValue() )
1079cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1080cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1083cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1084*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding)).getStr(),
1085*24c56ab9SHerbert Dürr *pCOL = (aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding)).getStr();
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir
1088cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle,
1089cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1090cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1091cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
1092cdf0e10cSrcweir (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
1093cdf0e10cSrcweir
1094cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1095cdf0e10cSrcweir checkColumnCount();
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir // -------------------------------------------------------------------------
openProcedures(const Any & catalog,const::rtl::OUString & schemaPattern,const::rtl::OUString & procedureNamePattern)1098cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const ::rtl::OUString& schemaPattern,
1099cdf0e10cSrcweir const ::rtl::OUString& procedureNamePattern)
1100cdf0e10cSrcweir throw(SQLException, RuntimeException)
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1103cdf0e10cSrcweir
1104cdf0e10cSrcweir if(schemaPattern.toChar() != '%')
1105cdf0e10cSrcweir pSchemaPat = &schemaPattern;
1106cdf0e10cSrcweir else
1107cdf0e10cSrcweir pSchemaPat = NULL;
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir m_bFreeHandle = sal_True;
1110cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir if ( catalog.hasValue() )
1113cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1114cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
1115cdf0e10cSrcweir
1116cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1117cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1118*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding)).getStr();
1119cdf0e10cSrcweir
1120cdf0e10cSrcweir
1121cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle,
1122cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1123cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1124cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
1125cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1126cdf0e10cSrcweir checkColumnCount();
1127cdf0e10cSrcweir }
1128cdf0e10cSrcweir // -------------------------------------------------------------------------
openSpecialColumns(sal_Bool _bRowVer,const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table,sal_Int32 scope,sal_Bool nullable)1129cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& catalog, const ::rtl::OUString& schema,
1130cdf0e10cSrcweir const ::rtl::OUString& table,sal_Int32 scope, sal_Bool nullable )
1131cdf0e10cSrcweir throw(SQLException, RuntimeException)
1132cdf0e10cSrcweir {
1133cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir if(schema.toChar() != '%')
1136cdf0e10cSrcweir pSchemaPat = &schema;
1137cdf0e10cSrcweir else
1138cdf0e10cSrcweir pSchemaPat = NULL;
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir m_bFreeHandle = sal_True;
1141cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
1142cdf0e10cSrcweir if ( catalog.hasValue() )
1143cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1144cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
1145cdf0e10cSrcweir
1146cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1147cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1148*24c56ab9SHerbert Dürr *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr();
1149cdf0e10cSrcweir
1150cdf0e10cSrcweir
1151cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID,
1152cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1153cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1154cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
1155cdf0e10cSrcweir (SQLSMALLINT)scope,
1156cdf0e10cSrcweir nullable ? SQL_NULLABLE : SQL_NO_NULLS);
1157cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1158cdf0e10cSrcweir checkColumnCount();
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir // -------------------------------------------------------------------------
openVersionColumns(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table)1161cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openVersionColumns(const Any& catalog, const ::rtl::OUString& schema,
1162cdf0e10cSrcweir const ::rtl::OUString& table) throw(SQLException, RuntimeException)
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir openSpecialColumns(sal_True,catalog,schema,table,SQL_SCOPE_TRANSACTION,sal_False);
1165cdf0e10cSrcweir }
1166cdf0e10cSrcweir // -------------------------------------------------------------------------
openBestRowIdentifier(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table,sal_Int32 scope,sal_Bool nullable)1167cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openBestRowIdentifier( const Any& catalog, const ::rtl::OUString& schema,
1168cdf0e10cSrcweir const ::rtl::OUString& table,sal_Int32 scope,sal_Bool nullable ) throw(SQLException, RuntimeException)
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir openSpecialColumns(sal_False,catalog,schema,table,scope,nullable);
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir // -------------------------------------------------------------------------
openForeignKeys(const Any & catalog,const::rtl::OUString * schema,const::rtl::OUString * table,const Any & catalog2,const::rtl::OUString * schema2,const::rtl::OUString * table2)1173cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const ::rtl::OUString* schema,
1174cdf0e10cSrcweir const ::rtl::OUString* table,
1175cdf0e10cSrcweir const Any& catalog2, const ::rtl::OUString* schema2,
1176cdf0e10cSrcweir const ::rtl::OUString* table2) throw(SQLException, RuntimeException)
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir m_bFreeHandle = sal_True;
1179cdf0e10cSrcweir
1180cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN;
1181cdf0e10cSrcweir if ( catalog.hasValue() )
1182cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1183cdf0e10cSrcweir if ( catalog2.hasValue() )
1184cdf0e10cSrcweir aFKQ = ::rtl::OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1187cdf0e10cSrcweir *pPKO = schema && schema->getLength() ? ::rtl::OUStringToOString(*schema,m_nTextEncoding).getStr() : NULL,
1188cdf0e10cSrcweir *pPKN = table ? (aPKN = ::rtl::OUStringToOString(*table,m_nTextEncoding)).getStr(): NULL,
1189cdf0e10cSrcweir *pFKQ = catalog2.hasValue() && aFKQ.getLength() ? aFKQ.getStr() : NULL,
1190cdf0e10cSrcweir *pFKO = schema2 && schema2->getLength() ? (aFKO = ::rtl::OUStringToOString(*schema2,m_nTextEncoding)).getStr() : NULL,
1191cdf0e10cSrcweir *pFKN = table2 ? (aFKN = ::rtl::OUStringToOString(*table2,m_nTextEncoding)).getStr() : NULL;
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir
1194cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle,
1195cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1196cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
1197cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, pPKN ? SQL_NTS : 0,
1198cdf0e10cSrcweir (SDB_ODBC_CHAR *) pFKQ, (catalog2.hasValue() && aFKQ.getLength()) ? SQL_NTS : 0,
1199cdf0e10cSrcweir (SDB_ODBC_CHAR *) pFKO, pFKO ? SQL_NTS : 0,
1200cdf0e10cSrcweir (SDB_ODBC_CHAR *) pFKN, SQL_NTS
1201cdf0e10cSrcweir );
1202cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1203cdf0e10cSrcweir checkColumnCount();
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir // -------------------------------------------------------------------------
openImportedKeys(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table)1206cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openImportedKeys(const Any& catalog, const ::rtl::OUString& schema,
1207cdf0e10cSrcweir const ::rtl::OUString& table) throw(SQLException, RuntimeException)
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir openForeignKeys(Any(),NULL,NULL,catalog,!schema.compareToAscii("%") ? &schema : NULL,&table);
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir // -------------------------------------------------------------------------
openExportedKeys(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table)1213cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openExportedKeys(const Any& catalog, const ::rtl::OUString& schema,
1214cdf0e10cSrcweir const ::rtl::OUString& table) throw(SQLException, RuntimeException)
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir openForeignKeys(catalog,!schema.compareToAscii("%") ? &schema : NULL,&table,Any(),NULL,NULL);
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir // -------------------------------------------------------------------------
openPrimaryKeys(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table)1219cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const ::rtl::OUString& schema,
1220cdf0e10cSrcweir const ::rtl::OUString& table) throw(SQLException, RuntimeException)
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1223cdf0e10cSrcweir
1224cdf0e10cSrcweir if(schema.toChar() != '%')
1225cdf0e10cSrcweir pSchemaPat = &schema;
1226cdf0e10cSrcweir else
1227cdf0e10cSrcweir pSchemaPat = NULL;
1228cdf0e10cSrcweir
1229cdf0e10cSrcweir m_bFreeHandle = sal_True;
1230cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
1231cdf0e10cSrcweir
1232cdf0e10cSrcweir if ( catalog.hasValue() )
1233cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1234cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
1235cdf0e10cSrcweir
1236cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1237cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1238cdf0e10cSrcweir *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr();
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir
1241cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle,
1242cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1243cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1244cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
1245cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1246cdf0e10cSrcweir checkColumnCount();
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir // -------------------------------------------------------------------------
openTablePrivileges(const Any & catalog,const::rtl::OUString & schemaPattern,const::rtl::OUString & tableNamePattern)1249cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const ::rtl::OUString& schemaPattern,
1250cdf0e10cSrcweir const ::rtl::OUString& tableNamePattern) throw(SQLException, RuntimeException)
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir if(schemaPattern.toChar() != '%')
1255cdf0e10cSrcweir pSchemaPat = &schemaPattern;
1256cdf0e10cSrcweir else
1257cdf0e10cSrcweir pSchemaPat = NULL;
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir m_bFreeHandle = sal_True;
1260cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN;
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir if ( catalog.hasValue() )
1263cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1264cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
1265cdf0e10cSrcweir
1266cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1267cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1268cdf0e10cSrcweir *pPKN = (aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr();
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir
1271cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle,
1272cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1273cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1274cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
1275cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1276cdf0e10cSrcweir checkColumnCount();
1277cdf0e10cSrcweir }
1278cdf0e10cSrcweir // -------------------------------------------------------------------------
openIndexInfo(const Any & catalog,const::rtl::OUString & schema,const::rtl::OUString & table,sal_Bool unique,sal_Bool approximate)1279cdf0e10cSrcweir void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const ::rtl::OUString& schema,
1280cdf0e10cSrcweir const ::rtl::OUString& table,sal_Bool unique,sal_Bool approximate )
1281cdf0e10cSrcweir throw(SQLException, RuntimeException)
1282cdf0e10cSrcweir {
1283cdf0e10cSrcweir const ::rtl::OUString *pSchemaPat = NULL;
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir if(schema.toChar() != '%')
1286cdf0e10cSrcweir pSchemaPat = &schema;
1287cdf0e10cSrcweir else
1288cdf0e10cSrcweir pSchemaPat = NULL;
1289cdf0e10cSrcweir
1290cdf0e10cSrcweir m_bFreeHandle = sal_True;
1291cdf0e10cSrcweir ::rtl::OString aPKQ,aPKO,aPKN;
1292cdf0e10cSrcweir
1293cdf0e10cSrcweir if ( catalog.hasValue() )
1294cdf0e10cSrcweir aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
1295cdf0e10cSrcweir aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
1296cdf0e10cSrcweir
1297cdf0e10cSrcweir const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
1298cdf0e10cSrcweir *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
1299cdf0e10cSrcweir *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr();
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle,
1303cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
1304cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
1305cdf0e10cSrcweir (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
1306cdf0e10cSrcweir unique ? SQL_INDEX_UNIQUE : SQL_INDEX_ALL,
1307cdf0e10cSrcweir approximate);
1308cdf0e10cSrcweir OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
1309cdf0e10cSrcweir checkColumnCount();
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir // -------------------------------------------------------------------------
checkColumnCount()1312cdf0e10cSrcweir void ODatabaseMetaDataResultSet::checkColumnCount()
1313cdf0e10cSrcweir {
1314cdf0e10cSrcweir sal_Int16 nNumResultCols=0;
1315cdf0e10cSrcweir OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
1316cdf0e10cSrcweir m_nDriverColumnCount = nNumResultCols;
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir // -----------------------------------------------------------------------------
1319cdf0e10cSrcweir
impl_getColumnType_nothrow(sal_Int32 columnIndex)1320cdf0e10cSrcweir SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
1323cdf0e10cSrcweir if ( aFind == m_aODBCColumnTypes.end() )
1324cdf0e10cSrcweir aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first;
1325cdf0e10cSrcweir return aFind->second;
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir
1328