LibreOffice Module connectivity (master) 1
OStatement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/sdbc/XStatement.hpp>
23#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24#include <com/sun/star/sdbc/XMultipleResults.hpp>
25#include <com/sun/star/sdbc/XBatchExecution.hpp>
26#include <com/sun/star/sdbc/XCloseable.hpp>
27#include <com/sun/star/sdbc/SQLWarning.hpp>
28#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
29#include <com/sun/star/util/XCancellable.hpp>
34#include <odbc/OFunctions.hxx>
35#include <odbc/OConnection.hxx>
37#include <string_view>
38#include <vector>
39#include <com/sun/star/lang/XServiceInfo.hpp>
40
41namespace connectivity::odbc
42 {
43
44 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
45 css::sdbc::XWarningsSupplier,
46 css::util::XCancellable,
47 css::sdbc::XCloseable,
48 css::sdbc::XGeneratedResultSet,
49 css::sdbc::XMultipleResults> OStatement_BASE;
50
51 class OResultSet;
52
53 //************ Class: java.sql.Statement
54
56 public cppu::BaseMutex,
57 public OStatement_BASE,
59 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
60
61 {
62 css::sdbc::SQLWarning m_aLastWarning;
63 protected:
64 css::uno::WeakReference< css::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
65 css::uno::Reference< css::sdbc::XStatement> m_xGeneratedStatement;
66 // for this Statement
67
68 std::vector< OUString> m_aBatchVector;
70
71 rtl::Reference<OConnection> m_pConnection;// The owning Connection object
73 SQLUSMALLINT* m_pRowStatusArray;
74
75 protected:
76
77 sal_Int64 getQueryTimeOut() const;
78 sal_Int64 getMaxFieldSize() const;
79 sal_Int64 getMaxRows() const;
80 sal_Int32 getResultSetConcurrency() const;
81 sal_Int32 getResultSetType() const;
82 sal_Int32 getFetchDirection() const;
83 sal_Int32 getFetchSize() const;
84 OUString getCursorName() const;
85 bool isUsingBookmarks() const;
86 bool getEscapeProcessing() const;
87 template < typename T, SQLINTEGER BufferLength > T getStmtOption (SQLINTEGER fOption) const;
88
89 void setQueryTimeOut(sal_Int64 _par0) ;
90 void setMaxFieldSize(sal_Int64 _par0) ;
91 void setMaxRows(sal_Int64 _par0) ;
92 void setFetchDirection(sal_Int32 _par0) ;
93 void setFetchSize(sal_Int32 _par0) ;
94 void setCursorName(std::u16string_view _par0);
95 void setEscapeProcessing( const bool _bEscapeProc );
96 template < typename T, SQLINTEGER BufferLength > SQLRETURN setStmtOption (SQLINTEGER fOption, T value) const;
97
98 void setResultSetConcurrency(sal_Int32 _par0) ;
99 void setResultSetType(sal_Int32 _par0) ;
100 void setUsingBookmarks(bool _bUseBookmark) ;
101
104 void reset();
107 void clearMyResultSet();
110 void setWarning (const css::sdbc::SQLWarning &ex);
113 bool lockIfNecessary (const OUString& sql);
116 sal_Int32 getColumnCount();
117
118
119 // getResultSet
120 // getResultSet returns the current result as a ResultSet. It
121 // returns NULL if the current result is not a ResultSet.
122
125 css::uno::Reference<css::sdbc::XResultSet> getResultSet(bool checkCount);
129 virtual rtl::Reference<OResultSet> createResultSet();
130
133 SQLLEN getRowCount();
134
135
136 void disposeResultSet();
137
138 // OPropertyArrayUsageHelper
139 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
140 // OPropertySetHelper
141 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
143 css::uno::Any & rConvertedValue,
144 css::uno::Any & rOldValue,
145 sal_Int32 nHandle,
146 const css::uno::Any& rValue ) override;
147 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
148 sal_Int32 nHandle,
149 const css::uno::Any& rValue
150 ) override;
151 virtual void SAL_CALL getFastPropertyValue(
152 css::uno::Any& rValue,
153 sal_Int32 nHandle
154 ) const override;
155 virtual ~OStatement_Base() override;
156
157 public:
158 OStatement_Base(OConnection* _pConnection );
159 using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
160
161 oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
162 {
163 return m_pConnection->getOdbcFunction(_nIndex);
164 }
165 // OComponentHelper
166 virtual void SAL_CALL disposing() override;
167 // XInterface
168 virtual void SAL_CALL release() noexcept override;
169 virtual void SAL_CALL acquire() noexcept override;
170 // XInterface
171 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
172 //XTypeProvider
173 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
174
175 // XPropertySet
176 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
177 // XStatement
178 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override ;
179 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override ;
180 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override ;
181 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override ;
182 // XWarningsSupplier
183 virtual css::uno::Any SAL_CALL getWarnings( ) override;
184 virtual void SAL_CALL clearWarnings( ) override;
185 // XCancellable
186 virtual void SAL_CALL cancel( ) override;
187 // XCloseable
188 virtual void SAL_CALL close( ) override;
189 // XMultipleResults
190 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
191 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
192 virtual sal_Bool SAL_CALL getMoreResults( ) override;
193 //XGeneratedResultSet
194 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) override;
195
196 // other methods
197 SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); }
198 OConnection* getOwnConnection() const { return m_pConnection.get();}
205 SQLUINTEGER getCursorProperties(SQLINTEGER _nCursorType, bool bFirst);
206
207 protected:
209 };
210
212 {
213 public:
215 OStatement_Base(_pConnection )
216 {}
217 // OComponentHelper
218 virtual void SAL_CALL disposing() override;
219 };
220
222 public OStatement_BASE2,
223 public css::sdbc::XBatchExecution,
224 public css::lang::XServiceInfo
225 {
226 protected:
227 virtual ~OStatement() override {}
228 public:
229 // A ctor that is needed for returning the object
230 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
232
233 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
234 virtual void SAL_CALL acquire() noexcept override;
235 virtual void SAL_CALL release() noexcept override;
236 // XBatchExecution
237 virtual void SAL_CALL addBatch( const OUString& sql ) override;
238 virtual void SAL_CALL clearBatch( ) override;
239 virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override;
240 };
241
242}
243
244/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ODBC3SQLFunctionId
Definition: OTools.hxx:33
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override final
OStatement_BASE2(OConnection *_pConnection)
Definition: OStatement.hxx:214
oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
Definition: OStatement.hxx:161
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet
Definition: OStatement.hxx:64
void setWarning(const css::sdbc::SQLWarning &ex)
css::uno::Reference< css::sdbc::XStatement > m_xGeneratedStatement
Definition: OStatement.hxx:65
std::vector< OUString > m_aBatchVector
Definition: OStatement.hxx:68
rtl::Reference< OConnection > m_pConnection
Definition: OStatement.hxx:71
OConnection * getOwnConnection() const
Definition: OStatement.hxx:198
css::sdbc::SQLWarning m_aLastWarning
Definition: OStatement.hxx:62
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
OStatement(OConnection *_pConnection)
Definition: OStatement.hxx:230
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual ~OStatement() override
Definition: OStatement.hxx:227
Type
::cppu::ImplHelper1< css::sdbc::XStatement > OStatement_Base
Definition: Statement.hxx:31
::cppu::WeakComponentImplHelper< css::sdbc::XStatement, css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable, css::sdbc::XGeneratedResultSet, css::sdbc::XMultipleResults > OStatement_BASE
Definition: OStatement.hxx:49
Reference< XConnection > getConnection(const Reference< XRowSet > &_rxRowSet)
Definition: dbtools.cxx:348
#define OOO_DLLPUBLIC_ODBCBASE
unsigned char sal_Bool