1079eb577SAndrew Rist /**************************************************************
2079eb577SAndrew Rist  *
3079eb577SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4079eb577SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5079eb577SAndrew Rist  * distributed with this work for additional information
6079eb577SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7079eb577SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8079eb577SAndrew Rist  * "License"); you may not use this file except in compliance
9079eb577SAndrew Rist  * with the License.  You may obtain a copy of the License at
10079eb577SAndrew Rist  *
11079eb577SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12079eb577SAndrew Rist  *
13079eb577SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14079eb577SAndrew Rist  * software distributed under the License is distributed on an
15079eb577SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16079eb577SAndrew Rist  * KIND, either express or implied.  See the License for the
17079eb577SAndrew Rist  * specific language governing permissions and limitations
18079eb577SAndrew Rist  * under the License.
19079eb577SAndrew Rist  *
20079eb577SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir #include <stdio.h>
22cdf0e10cSrcweir #include "mysqlc_connection.hxx"
23cdf0e10cSrcweir #include "mysqlc_propertyids.hxx"
24cdf0e10cSrcweir #include "mysqlc_resultset.hxx"
25cdf0e10cSrcweir #include "mysqlc_statement.hxx"
26cdf0e10cSrcweir #include "mysqlc_general.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <cppconn/connection.h>
34cdf0e10cSrcweir #include <cppconn/exception.h>
35cdf0e10cSrcweir #include <cppconn/statement.h>
36cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
37cdf0e10cSrcweir #include <osl/diagnose.h>
38cdf0e10cSrcweir #include <osl/thread.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define USE_CPP_CONN 1
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using namespace connectivity::mysqlc;
43cdf0e10cSrcweir //------------------------------------------------------------------------------
44cdf0e10cSrcweir using namespace com::sun::star::uno;
45cdf0e10cSrcweir using namespace com::sun::star::lang;
46cdf0e10cSrcweir using namespace com::sun::star::beans;
47cdf0e10cSrcweir using namespace com::sun::star::sdbc;
48cdf0e10cSrcweir using namespace com::sun::star::sdbcx;
49cdf0e10cSrcweir using namespace com::sun::star::container;
50cdf0e10cSrcweir using namespace com::sun::star::io;
51cdf0e10cSrcweir using namespace com::sun::star::util;
52cdf0e10cSrcweir using ::osl::MutexGuard;
53cdf0e10cSrcweir using ::rtl::OUString;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #include <stdio.h>
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /* {{{ OConnection::OCommonStatement() -I- */
OCommonStatement(OConnection * _pConnection,sql::Statement * _cppStatement)58cdf0e10cSrcweir OCommonStatement::OCommonStatement(OConnection* _pConnection, sql::Statement *_cppStatement)
59cdf0e10cSrcweir 	:OCommonStatement_IBase(m_aMutex)
60cdf0e10cSrcweir 	,OPropertySetHelper(OCommonStatement_IBase::rBHelper)
61cdf0e10cSrcweir     ,OStatement_CBase( (::cppu::OWeakObject*)_pConnection, this )
62cdf0e10cSrcweir 	,m_pConnection(_pConnection)
63cdf0e10cSrcweir 	,cppStatement(_cppStatement)
64cdf0e10cSrcweir 	,rBHelper(OCommonStatement_IBase::rBHelper)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::OCommonStatement");
67cdf0e10cSrcweir 	m_pConnection->acquire();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir /* }}} */
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /* {{{ OConnection::~OCommonStatement() -I- */
~OCommonStatement()73cdf0e10cSrcweir OCommonStatement::~OCommonStatement()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::~OCommonStatement");
76cdf0e10cSrcweir }
77cdf0e10cSrcweir /* }}} */
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /* {{{ OConnection::disposeResultSet() -I- */
disposeResultSet()81cdf0e10cSrcweir void OCommonStatement::disposeResultSet()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::disposeResultSet");
84cdf0e10cSrcweir 	// free the cursor if alive
85cdf0e10cSrcweir 	delete cppStatement;
86cdf0e10cSrcweir 	cppStatement = NULL;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir /* }}} */
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /* {{{ OConnection::disposing() -I- */
disposing()92cdf0e10cSrcweir void OCommonStatement::disposing()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::disposing");
95cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	disposeResultSet();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     if (m_pConnection) {
100cdf0e10cSrcweir 		m_pConnection->release();
101cdf0e10cSrcweir 		m_pConnection = NULL;
102cdf0e10cSrcweir 	}
103cdf0e10cSrcweir 	delete cppStatement;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     dispose_ChildImpl();
106cdf0e10cSrcweir 	OCommonStatement_IBase::disposing();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir /* }}} */
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir /* {{{ OCommonStatement::queryInterface() -I- */
queryInterface(const Type & rType)112cdf0e10cSrcweir Any SAL_CALL OCommonStatement::queryInterface(const Type & rType)
113cdf0e10cSrcweir 	throw(RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::queryInterface");
116cdf0e10cSrcweir 	Any aRet = OCommonStatement_IBase::queryInterface(rType);
117cdf0e10cSrcweir 	if (!aRet.hasValue()) {
118cdf0e10cSrcweir 		aRet = OPropertySetHelper::queryInterface(rType);
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 	return aRet;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir /* }}} */
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir /* {{{ OCommonStatement::getTypes() -I- */
getTypes()126cdf0e10cSrcweir Sequence< Type > SAL_CALL OCommonStatement::getTypes()
127cdf0e10cSrcweir 	throw(RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getTypes");
130cdf0e10cSrcweir 	::cppu::OTypeCollection aTypes(	::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
131cdf0e10cSrcweir 									::getCppuType( (const Reference< XFastPropertySet > *)0 ),
132cdf0e10cSrcweir 									::getCppuType( (const Reference< XPropertySet > *)0 ));
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 	return concatSequences(aTypes.getTypes(), OCommonStatement_IBase::getTypes());
135cdf0e10cSrcweir }
136cdf0e10cSrcweir /* }}} */
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir /* {{{ OCommonStatement::cancel() -I- */
cancel()140cdf0e10cSrcweir void SAL_CALL OCommonStatement::cancel()
141cdf0e10cSrcweir 	throw(RuntimeException)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::cancel");
144cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
145cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
146cdf0e10cSrcweir 	// cancel the current sql statement
147cdf0e10cSrcweir }
148cdf0e10cSrcweir /* }}} */
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 
151cdf0e10cSrcweir /* {{{ OCommonStatement::close() -I- */
close()152cdf0e10cSrcweir void SAL_CALL OCommonStatement::close()
153cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::close");
156cdf0e10cSrcweir 	/*
157cdf0e10cSrcweir 	  We need a block for the checkDisposed call.
158cdf0e10cSrcweir 	  After the check we can call dispose() as we are not under lock ??
159cdf0e10cSrcweir 	*/
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		MutexGuard aGuard(m_aMutex);
162cdf0e10cSrcweir 		checkDisposed(rBHelper.bDisposed);
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir 	dispose();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir /* }}} */
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir /* {{{ OStatement::clearBatch() -I- */
clearBatch()170cdf0e10cSrcweir void SAL_CALL OStatement::clearBatch()
171cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	OSL_TRACE("OStatement::clearBatch");
174cdf0e10cSrcweir 	// if you support batches clear it here
175cdf0e10cSrcweir }
176cdf0e10cSrcweir /* }}} */
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir /* {{{ OStatement::execute() -I- */
execute(const OUString & sql)180cdf0e10cSrcweir sal_Bool SAL_CALL OCommonStatement::execute(const OUString& sql)
181cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::execute");
184cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
185cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
186cdf0e10cSrcweir     const ::rtl::OUString sSqlStatement = m_pConnection->transFormPreparedStatement( sql );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     sal_Bool success = false;
189cdf0e10cSrcweir 	try {
190cdf0e10cSrcweir 		success = cppStatement->execute(OUStringToOString(sSqlStatement, m_pConnection->getConnectionSettings().encoding).getStr())? sal_True:sal_False;
191cdf0e10cSrcweir 	} catch (sql::SQLException &e) {
192cdf0e10cSrcweir         mysqlc_sdbc_driver::translateAndThrow(e, *this, m_pConnection->getConnectionEncoding());
193cdf0e10cSrcweir 	}
194cdf0e10cSrcweir     return success;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir /* }}} */
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 
199cdf0e10cSrcweir /* {{{ OStatement::executeQuery() -I- */
executeQuery(const OUString & sql)200cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery(const OUString& sql)
201cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::executeQuery");
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
206cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
207cdf0e10cSrcweir     const ::rtl::OUString sSqlStatement = m_pConnection->transFormPreparedStatement(sql);
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     Reference< XResultSet > xResultSet;
210cdf0e10cSrcweir 	try {
211cdf0e10cSrcweir 		std::auto_ptr< sql::ResultSet > rset(cppStatement->executeQuery(OUStringToOString(sSqlStatement, m_pConnection->getConnectionEncoding()).getStr()));
212cdf0e10cSrcweir 		xResultSet = new OResultSet(this, rset.get(), m_pConnection->getConnectionEncoding());
213cdf0e10cSrcweir 		rset.release();
214cdf0e10cSrcweir 	} catch (sql::SQLException &e) {
215cdf0e10cSrcweir         mysqlc_sdbc_driver::translateAndThrow(e, *this, m_pConnection->getConnectionEncoding());
216cdf0e10cSrcweir 	}
217cdf0e10cSrcweir     return xResultSet;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir /* }}} */
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
222cdf0e10cSrcweir /* {{{ OStatement::getConnection() -I- */
getConnection()223cdf0e10cSrcweir Reference< XConnection > SAL_CALL OCommonStatement::getConnection()
224cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getConnection");
227cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
228cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	// just return(our connection here
231cdf0e10cSrcweir 	return ((Reference< XConnection >)m_pConnection);
232cdf0e10cSrcweir }
233cdf0e10cSrcweir /* }}} */
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 
236cdf0e10cSrcweir /* {{{ OStatement::getUpdateCount() -I- */
getUpdateCount()237cdf0e10cSrcweir sal_Int32 SAL_CALL OCommonStatement::getUpdateCount()
238cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getUpdateCount");
241cdf0e10cSrcweir 	return 0;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir /* }}} */
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 
246cdf0e10cSrcweir /* {{{ OStatement::queryInterface() -I- */
queryInterface(const Type & rType)247cdf0e10cSrcweir Any SAL_CALL OStatement::queryInterface(const Type & rType)
248cdf0e10cSrcweir 	throw(RuntimeException)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir 	OSL_TRACE("OStatement::queryInterface");
251cdf0e10cSrcweir 	Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
252cdf0e10cSrcweir 	if (!aRet.hasValue()) {
253cdf0e10cSrcweir 		aRet = OCommonStatement::queryInterface(rType);
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 	return (aRet);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir /* }}} */
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 
260cdf0e10cSrcweir /* {{{ OStatement::addBatch() -I- */
addBatch(const OUString & sql)261cdf0e10cSrcweir void SAL_CALL OStatement::addBatch(const OUString& sql)
262cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir 	OSL_TRACE("OStatement::addBatch");
265cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
266cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	m_aBatchList.push_back(sql);
269cdf0e10cSrcweir }
270cdf0e10cSrcweir /* }}} */
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 
273cdf0e10cSrcweir /* {{{ OStatement::executeBatch() -I- */
executeBatch()274cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch()
275cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	OSL_TRACE("OStatement::executeBatch");
278cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
279cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	Sequence< sal_Int32 > aRet = Sequence< sal_Int32 >();
282cdf0e10cSrcweir 	return aRet;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir /* }}} */
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 
287cdf0e10cSrcweir /* {{{ OCommonStatement::executeUpdate() -I- */
executeUpdate(const OUString & sql)288cdf0e10cSrcweir sal_Int32 SAL_CALL OCommonStatement::executeUpdate(const OUString& sql)
289cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::executeUpdate");
292cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
293cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
294cdf0e10cSrcweir     const ::rtl::OUString sSqlStatement = m_pConnection->transFormPreparedStatement(sql);
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     sal_Int32 affectedRows = 0;
297cdf0e10cSrcweir 	try {
298cdf0e10cSrcweir 		affectedRows = cppStatement->executeUpdate(OUStringToOString(sSqlStatement, m_pConnection->getConnectionEncoding()).getStr());
299cdf0e10cSrcweir 	} catch (sql::SQLException &e) {
300cdf0e10cSrcweir         mysqlc_sdbc_driver::translateAndThrow(e, *this, m_pConnection->getConnectionEncoding());
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir     return affectedRows;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir /* }}} */
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 
307cdf0e10cSrcweir /* {{{ OCommonStatement::getResultSet() -I- */
getResultSet()308cdf0e10cSrcweir Reference< XResultSet > SAL_CALL OCommonStatement::getResultSet()
309cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getResultSet");
312cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
313cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     Reference< XResultSet > xResultSet;
316cdf0e10cSrcweir 	try {
317cdf0e10cSrcweir 		std::auto_ptr< sql::ResultSet > rset(cppStatement->getResultSet());
318cdf0e10cSrcweir 		xResultSet = new OResultSet(this, rset.get(), m_pConnection->getConnectionEncoding());
319cdf0e10cSrcweir 		rset.release();
320cdf0e10cSrcweir 	} catch (sql::SQLException &e) {
321cdf0e10cSrcweir         mysqlc_sdbc_driver::translateAndThrow(e, *this, m_pConnection->getConnectionEncoding());
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir     return xResultSet;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir /* }}} */
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 
328cdf0e10cSrcweir /* {{{ OCommonStatement::getMoreResults() -I- */
getMoreResults()329cdf0e10cSrcweir sal_Bool SAL_CALL OCommonStatement::getMoreResults()
330cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
331cdf0e10cSrcweir {
332cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getMoreResults");
333cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
334cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	// if your driver supports more than only one resultset
337cdf0e10cSrcweir 	// and has one more at this moment return(true
338cdf0e10cSrcweir 	return (sal_False);
339cdf0e10cSrcweir }
340cdf0e10cSrcweir /* }}} */
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 
343cdf0e10cSrcweir /* {{{ OCommonStatement::getWarnings() -I- */
getWarnings()344cdf0e10cSrcweir Any SAL_CALL OCommonStatement::getWarnings()
345cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getWarnings");
348cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
349cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	return makeAny(m_aLastWarning);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir /* }}} */
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 
356cdf0e10cSrcweir /* {{{ OCommonStatement::clearWarnings() -I- */
clearWarnings()357cdf0e10cSrcweir void SAL_CALL OCommonStatement::clearWarnings()
358cdf0e10cSrcweir 	throw(SQLException, RuntimeException)
359cdf0e10cSrcweir {
360cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::clearWarnings");
361cdf0e10cSrcweir 	MutexGuard aGuard(m_aMutex);
362cdf0e10cSrcweir 	checkDisposed(rBHelper.bDisposed);
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	m_aLastWarning = SQLWarning();
365cdf0e10cSrcweir }
366cdf0e10cSrcweir /* }}} */
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 
369cdf0e10cSrcweir /* {{{ OCommonStatement::createArrayHelper() -I- */
createArrayHelper() const370cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const
371cdf0e10cSrcweir {
372cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::createArrayHelper");
373cdf0e10cSrcweir 	// this properties are define by the service statement
374cdf0e10cSrcweir 	// they must in alphabetic order
375cdf0e10cSrcweir 	Sequence< Property > aProps(10);
376cdf0e10cSrcweir 	Property* pProperties = aProps.getArray();
377cdf0e10cSrcweir 	sal_Int32 nPos = 0;
378cdf0e10cSrcweir 	DECL_PROP0(CURSORNAME,	OUString);
379cdf0e10cSrcweir 	DECL_BOOL_PROP0(ESCAPEPROCESSING);
380cdf0e10cSrcweir 	DECL_PROP0(FETCHDIRECTION,sal_Int32);
381cdf0e10cSrcweir 	DECL_PROP0(FETCHSIZE,	sal_Int32);
382cdf0e10cSrcweir 	DECL_PROP0(MAXFIELDSIZE,sal_Int32);
383cdf0e10cSrcweir 	DECL_PROP0(MAXROWS,		sal_Int32);
384cdf0e10cSrcweir 	DECL_PROP0(QUERYTIMEOUT,sal_Int32);
385cdf0e10cSrcweir 	DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
386cdf0e10cSrcweir 	DECL_PROP0(RESULTSETTYPE,sal_Int32);
387cdf0e10cSrcweir 	DECL_BOOL_PROP0(USEBOOKMARKS);
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aProps);
390cdf0e10cSrcweir }
391cdf0e10cSrcweir /* }}} */
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir /* {{{ OCommonStatement::getInfoHelper() -I- */
getInfoHelper()395cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper()
396cdf0e10cSrcweir {
397cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getInfoHelper");
398cdf0e10cSrcweir 	return(*const_cast<OCommonStatement*>(this)->getArrayHelper());
399cdf0e10cSrcweir }
400cdf0e10cSrcweir /* }}} */
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 
403cdf0e10cSrcweir /* {{{ OCommonStatement::convertFastPropertyValue() -I- */
convertFastPropertyValue(Any &,Any &,sal_Int32,const Any &)404cdf0e10cSrcweir sal_Bool OCommonStatement::convertFastPropertyValue(
405cdf0e10cSrcweir 		Any & /* rConvertedValue */, Any & /* rOldValue */,
406cdf0e10cSrcweir 		sal_Int32 /* nHandle */, const Any& /* rValue */)
407cdf0e10cSrcweir 	throw (IllegalArgumentException)
408cdf0e10cSrcweir {
409cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::convertFastPropertyValue");
410cdf0e10cSrcweir 	sal_Bool bConverted = sal_False;
411cdf0e10cSrcweir 	// here we have to try to convert
412cdf0e10cSrcweir 	return bConverted;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir /* }}} */
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 
417cdf0e10cSrcweir /* {{{ OCommonStatement::setFastPropertyValue_NoBroadcast() -I- */
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any &)418cdf0e10cSrcweir void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& /* rValue */)
419cdf0e10cSrcweir 	throw (Exception)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::setFastPropertyValue_NoBroadcast");
422*a893be29SPedro Giffuni 	// set the value to what ever is necessary
423cdf0e10cSrcweir 	switch (nHandle) {
424cdf0e10cSrcweir 		case PROPERTY_ID_QUERYTIMEOUT:
425cdf0e10cSrcweir 		case PROPERTY_ID_MAXFIELDSIZE:
426cdf0e10cSrcweir 		case PROPERTY_ID_MAXROWS:
427cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
428cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
429cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
430cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
431cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
432cdf0e10cSrcweir 		case PROPERTY_ID_ESCAPEPROCESSING:
433cdf0e10cSrcweir 		case PROPERTY_ID_USEBOOKMARKS:
434cdf0e10cSrcweir 		default:
435cdf0e10cSrcweir 			;
436cdf0e10cSrcweir 	}
437cdf0e10cSrcweir }
438cdf0e10cSrcweir /* }}} */
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 
441cdf0e10cSrcweir /* {{{ OCommonStatement::getFastPropertyValue() -I- */
getFastPropertyValue(Any & _rValue,sal_Int32 nHandle) const442cdf0e10cSrcweir void OCommonStatement::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) const
443cdf0e10cSrcweir {
444cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getFastPropertyValue");
445cdf0e10cSrcweir 	switch (nHandle)	{
446cdf0e10cSrcweir 		case PROPERTY_ID_QUERYTIMEOUT:
447cdf0e10cSrcweir 		case PROPERTY_ID_MAXFIELDSIZE:
448cdf0e10cSrcweir 		case PROPERTY_ID_MAXROWS:
449cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
450cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
451cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
452cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
453cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
454cdf0e10cSrcweir 		case PROPERTY_ID_ESCAPEPROCESSING:
455cdf0e10cSrcweir 			break;
456cdf0e10cSrcweir 		case PROPERTY_ID_USEBOOKMARKS:
457cdf0e10cSrcweir             _rValue <<= sal_False;
458cdf0e10cSrcweir             break;
459cdf0e10cSrcweir 		default:
460cdf0e10cSrcweir 			;
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir }
463cdf0e10cSrcweir /* }}} */
464cdf0e10cSrcweir 
465cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
466cdf0e10cSrcweir 
467cdf0e10cSrcweir /* {{{ OCommonStatement::acquire() -I- */
acquire()468cdf0e10cSrcweir void SAL_CALL OCommonStatement::acquire()
469cdf0e10cSrcweir 	throw()
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::acquire");
472cdf0e10cSrcweir 	OCommonStatement_IBase::acquire();
473cdf0e10cSrcweir }
474cdf0e10cSrcweir /* }}} */
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 
477cdf0e10cSrcweir /* {{{ OCommonStatement::release() -I- */
release()478cdf0e10cSrcweir void SAL_CALL OCommonStatement::release()
479cdf0e10cSrcweir 	throw()
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::release");
482cdf0e10cSrcweir     relase_ChildImpl();
483cdf0e10cSrcweir }
484cdf0e10cSrcweir /* }}} */
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 
487cdf0e10cSrcweir /* {{{ OStatement::acquire() -I- */
acquire()488cdf0e10cSrcweir void SAL_CALL OStatement::acquire()
489cdf0e10cSrcweir 	throw()
490cdf0e10cSrcweir {
491cdf0e10cSrcweir 	OSL_TRACE("OStatement::acquire");
492cdf0e10cSrcweir 	OCommonStatement::acquire();
493cdf0e10cSrcweir }
494cdf0e10cSrcweir /* }}} */
495cdf0e10cSrcweir 
496cdf0e10cSrcweir 
497cdf0e10cSrcweir /* {{{ OStatement::release() -I- */
release()498cdf0e10cSrcweir void SAL_CALL OStatement::release()
499cdf0e10cSrcweir 	throw()
500cdf0e10cSrcweir {
501cdf0e10cSrcweir 	OSL_TRACE("OStatement::release");
502cdf0e10cSrcweir 	OCommonStatement::release();
503cdf0e10cSrcweir }
504cdf0e10cSrcweir /* }}} */
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 
507cdf0e10cSrcweir /* {{{ OCommonStatement::getPropertySetInfo() -I- */
getPropertySetInfo()508cdf0e10cSrcweir Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo()
509cdf0e10cSrcweir 	throw(RuntimeException)
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	OSL_TRACE("OCommonStatement::getPropertySetInfo");
512cdf0e10cSrcweir 	return(::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()));
513cdf0e10cSrcweir }
514cdf0e10cSrcweir /* }}} */
515cdf0e10cSrcweir 
516cdf0e10cSrcweir /*
517cdf0e10cSrcweir  * Local variables:
518cdf0e10cSrcweir  * tab-width: 4
519cdf0e10cSrcweir  * c-basic-offset: 4
520cdf0e10cSrcweir  * End:
521cdf0e10cSrcweir  * vim600: noet sw=4 ts=4 fdm=marker
522cdf0e10cSrcweir  * vim<600: noet sw=4 ts=4
523cdf0e10cSrcweir  */
524