LibreOffice Module connectivity (master) 1
pq_preparedstatement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * Effective License of whole file:
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 *
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 *
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
24 *
25 * Copyright: 2000 by Sun Microsystems, Inc.
26 *
27 * Contributor(s): Joerg Budischewski
28 *
29 * All parts contributed on or after August 2011:
30 *
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
34 *
35 ************************************************************************/
36
37#pragma once
38#include <vector>
39
40#include <libpq-fe.h>
41
44
45#include <com/sun/star/sdbc/XParameters.hpp>
46#include <com/sun/star/sdbc/XMultipleResults.hpp>
47#include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
48#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
49
50#include "pq_connection.hxx"
51namespace pq_sdbc_driver
52{
53
59const sal_Int32 PREPARED_STATEMENT_MAX_ROWS = 5;
63
64#define PREPARED_STATEMENT_SIZE 9
65
66typedef ::cppu::WeakComponentImplHelper< css::sdbc::XPreparedStatement,
67 css::sdbc::XParameters,
68 css::sdbc::XCloseable,
69 css::sdbc::XWarningsSupplier,
70 css::sdbc::XMultipleResults,
71 css::sdbc::XGeneratedResultSet,
72 css::sdbc::XResultSetMetaDataSupplier
76{
77private:
79 css::uno::Reference< css::sdbc::XConnection > m_connection;
81 css::uno::Reference< css::sdbc::XCloseable > m_lastResultset;
82 OString m_stmt;
85 std::vector< OString > m_vars;
86 std::vector< OString > m_splittedStatement;
91 OString m_lastQuery;
92
93public:
99 const css::uno::Reference< css::sdbc::XConnection> & con,
100 struct ConnectionSettings *pSettings,
101 OString stmt );
102
103 virtual ~PreparedStatement() override;
104public: // XInterface
105 virtual void SAL_CALL acquire() noexcept override { PreparedStatement_BASE::acquire(); }
106 virtual void SAL_CALL release() noexcept override { PreparedStatement_BASE::release(); }
107 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & reqType ) override;
108
109public: // XCloseable
110 virtual void SAL_CALL close( ) override;
111
112public: // XPreparedStatement
113 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override;
114 virtual sal_Int32 SAL_CALL executeUpdate( ) override;
115 virtual sal_Bool SAL_CALL execute( ) override;
116 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
117public: // XParameters
118 virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) override;
119 virtual void SAL_CALL setObjectNull(
120 sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& typeName ) override;
121 virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) override;
122 virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) override;
123 virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) override;
124 virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) override;
125 virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) override;
126 virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) override;
127 virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) override;
128 virtual void SAL_CALL setString( sal_Int32 parameterIndex, const OUString& x ) override;
129 virtual void SAL_CALL setBytes(
130 sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 >& x ) override;
131 virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const css::util::Date& x ) override;
132 virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const css::util::Time& x ) override;
133 virtual void SAL_CALL setTimestamp(
134 sal_Int32 parameterIndex, const css::util::DateTime& x ) override;
135 virtual void SAL_CALL setBinaryStream(
136 sal_Int32 parameterIndex,
137 const css::uno::Reference< css::io::XInputStream >& x,
138 sal_Int32 length ) override;
139 virtual void SAL_CALL setCharacterStream(
140 sal_Int32 parameterIndex,
141 const css::uno::Reference< css::io::XInputStream >& x,
142 sal_Int32 length ) override;
143 virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const css::uno::Any& x ) override;
144 virtual void SAL_CALL setObjectWithInfo(
145 sal_Int32 parameterIndex,
146 const css::uno::Any& x,
147 sal_Int32 targetSqlType,
148 sal_Int32 scale ) override;
149 virtual void SAL_CALL setRef(
150 sal_Int32 parameterIndex,
151 const css::uno::Reference< css::sdbc::XRef >& x ) override;
152 virtual void SAL_CALL setBlob(
153 sal_Int32 parameterIndex,
154 const css::uno::Reference< css::sdbc::XBlob >& x ) override;
155 virtual void SAL_CALL setClob(
156 sal_Int32 parameterIndex,
157 const css::uno::Reference< css::sdbc::XClob >& x ) override;
158 virtual void SAL_CALL setArray(
159 sal_Int32 parameterIndex,
160 const css::uno::Reference< css::sdbc::XArray >& x ) override;
161 virtual void SAL_CALL clearParameters( ) override;
162
163public: // XWarningsSupplier
164 virtual css::uno::Any SAL_CALL getWarnings( ) override;
165 virtual void SAL_CALL clearWarnings( ) override;
166
167public: // XTypeProvider, first implemented by OPropertySetHelper
168 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
169 virtual css::uno::Sequence< sal_Int8> SAL_CALL getImplementationId() override;
170
171public: // OPropertySetHelper
172 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
173
174 virtual sal_Bool SAL_CALL convertFastPropertyValue(
175 css::uno::Any & rConvertedValue,
176 css::uno::Any & rOldValue,
177 sal_Int32 nHandle,
178 const css::uno::Any& rValue ) override;
179
180 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
181 sal_Int32 nHandle,
182 const css::uno::Any& rValue ) override;
183
184 using ::cppu::OPropertySetHelper::getFastPropertyValue;
185
186 void SAL_CALL getFastPropertyValue(
187 css::uno::Any& rValue,
188 sal_Int32 nHandle ) const override;
189
190 // XPropertySet
191 css::uno::Reference < css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
192
193public: // XGeneratedResultSet
194 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL
195 getGeneratedValues( ) override;
196
197public: // XMultipleResults
198 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
199 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
200 virtual sal_Bool SAL_CALL getMoreResults( ) override;
201
202public: // XResultSetMetaDataSupplier (is required by framework (see
203 // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
204 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
205
206public: // OComponentHelper
207 virtual void SAL_CALL disposing() override;
208
209private:
210 void checkColumnIndex( sal_Int32 parameterIndex );
213 void checkClosed();
215 void raiseSQLException( const char * errorMsg );
216// PGresult *pgExecute( OString *pQuery );
217};
218
219}
220
221/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime &x) override
virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) override
virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) override
virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) override
css::uno::Reference< css::sdbc::XConnection > m_connection
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues() override
virtual void SAL_CALL close() override
virtual cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual sal_Bool SAL_CALL execute() override
void checkColumnIndex(sal_Int32 parameterIndex)
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Int32 SAL_CALL executeUpdate() override
virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob > &x) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override
virtual void SAL_CALL release() noexcept override
virtual sal_Int32 SAL_CALL getUpdateCount() override
virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const css::uno::Any &x) override
virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setString(sal_Int32 parameterIndex, const OUString &x) override
virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef > &x) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const css::uno::Any &x, sal_Int32 targetSqlType, sal_Int32 scale) override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
virtual void SAL_CALL acquire() noexcept override
css::uno::Reference< css::sdbc::XCloseable > m_lastResultset
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) override
virtual void SAL_CALL clearParameters() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual sal_Bool SAL_CALL getMoreResults() override
virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const css::util::Time &x) override
virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString &typeName) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
std::vector< OString > m_splittedStatement
virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 > &x) override
virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) override
virtual void SAL_CALL clearWarnings() override
virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray > &x) override
css::uno::Any m_props[PREPARED_STATEMENT_SIZE]
void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) override
virtual css::uno::Any SAL_CALL getWarnings() override
virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const css::util::Date &x) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
PreparedStatement(const rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &con, struct ConnectionSettings *pSettings, OString stmt)
void raiseSQLException(const char *errorMsg)
virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob > &x) override
const sal_Int32 PREPARED_STATEMENT_FETCH_DIRECTION
const sal_Int32 PREPARED_STATEMENT_MAX_FIELD_SIZE
const sal_Int32 PREPARED_STATEMENT_RESULT_SET_TYPE
const sal_Int32 PREPARED_STATEMENT_QUERY_TIME_OUT
const sal_Int32 PREPARED_STATEMENT_ESCAPE_PROCESSING
::cppu::WeakComponentImplHelper< css::sdbc::XPreparedStatement, css::sdbc::XParameters, css::sdbc::XCloseable, css::sdbc::XWarningsSupplier, css::sdbc::XMultipleResults, css::sdbc::XGeneratedResultSet, css::sdbc::XResultSetMetaDataSupplier > PreparedStatement_BASE
const sal_Int32 PREPARED_STATEMENT_FETCH_SIZE
const sal_Int32 PREPARED_STATEMENT_RESULT_SET_CONCURRENCY
const sal_Int32 PREPARED_STATEMENT_CURSOR_NAME
const sal_Int32 PREPARED_STATEMENT_MAX_ROWS
OUString typeName
#define PREPARED_STATEMENT_SIZE
sal_Int32 scale
Definition: pq_statics.cxx:62
unsigned char sal_Bool
signed char sal_Int8