1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "Connection.hxx"
21 #include "ResultSet.hxx"
22 #include "Statement.hxx"
25 #include <comphelper/sequence.hxx>
26 #include <cppuhelper/queryinterface.hxx>
27 #include <sal/log.hxx>
29 using namespace connectivity::firebird
;
31 using namespace com::sun::star
;
32 using namespace com::sun::star::uno
;
33 using namespace com::sun::star::lang
;
34 using namespace com::sun::star::beans
;
35 using namespace com::sun::star::sdbc
;
36 using namespace com::sun::star::sdbcx
;
37 using namespace com::sun::star::container
;
38 using namespace com::sun::star::io
;
39 using namespace com::sun::star::util
;
41 using namespace ::comphelper
;
42 using namespace ::osl
;
43 using namespace ::std
;
45 // ---- XBatchExecution - UNSUPPORTED ----------------------------------------
46 void SAL_CALL
OStatement::addBatch(const OUString
&)
50 void SAL_CALL
OStatement::clearBatch()
54 Sequence
< sal_Int32
> SAL_CALL
OStatement::executeBatch()
56 return Sequence
< sal_Int32
>();
59 IMPLEMENT_SERVICE_INFO(OStatement
,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
61 void SAL_CALL
OStatement::acquire() noexcept
63 OStatementCommonBase::acquire();
66 void SAL_CALL
OStatement::release() noexcept
68 OStatementCommonBase::release();
71 void OStatement::disposeResultSet()
73 MutexGuard
aGuard(m_aMutex
);
74 checkDisposed(OStatementCommonBase_Base::rBHelper
.bDisposed
);
76 OStatementCommonBase::disposeResultSet();
86 // ---- XStatement -----------------------------------------------------------
87 sal_Int32 SAL_CALL
OStatement::executeUpdate(const OUString
& sql
)
90 return getStatementChangeCount();
94 uno::Reference
< XResultSet
> SAL_CALL
OStatement::executeQuery(const OUString
& sql
)
96 MutexGuard
aGuard(m_aMutex
);
97 checkDisposed(OStatementCommonBase_Base::rBHelper
.bDisposed
);
99 SAL_INFO("connectivity.firebird", "executeQuery(" << sql
<< ")");
105 prepareAndDescribeStatement(sql
,
108 aErr
= isc_dsql_execute(m_statusVector
,
109 &m_pConnection
->getTransaction(),
114 SAL_WARN("connectivity.firebird", "isc_dsql_execute failed");
116 m_xResultSet
= new OResultSet(m_pConnection
.get(),
118 uno::Reference
< XInterface
>(*this),
122 // TODO: deal with cleanup
124 evaluateStatusVector(m_statusVector
, sql
, *this);
126 if (isDDLStatement())
128 m_pConnection
->commit();
129 m_pConnection
->notifyDatabaseModified();
131 else if (getStatementChangeCount() > 0)
133 m_pConnection
->notifyDatabaseModified();
139 sal_Bool SAL_CALL
OStatement::execute(const OUString
& sql
)
141 uno::Reference
< XResultSet
> xResults
= executeQuery(sql
);
142 return xResults
.is();
143 // TODO: what if we have multiple results?
146 uno::Reference
< XConnection
> SAL_CALL
OStatement::getConnection()
148 MutexGuard
aGuard(m_aMutex
);
149 checkDisposed(OStatementCommonBase_Base::rBHelper
.bDisposed
);
151 return m_pConnection
;
154 Any SAL_CALL
OStatement::queryInterface( const Type
& rType
)
156 Any aRet
= OStatement_Base::queryInterface(rType
);
158 aRet
= ::cppu::queryInterface(rType
,static_cast< XBatchExecution
*> (this));
160 aRet
= OStatementCommonBase::queryInterface(rType
);
164 uno::Sequence
< Type
> SAL_CALL
OStatement::getTypes()
166 return concatSequences(OStatement_Base::getTypes(),
167 OStatementCommonBase::getTypes());
170 void SAL_CALL
OStatement::disposing()
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */