merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / postgresql / pq_statement.hxx
blob298ac13c5a35b94863a6350f4a92722782aa20b9
1 /*************************************************************************
3 * $RCSfile: pq_statement.hxx,v $
5 * $Revision: 1.1.2.3 $
7 * last change: $Author: jbu $ $Date: 2006/01/22 15:14:34 $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Joerg Budischewski
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Joerg Budischewski
60 ************************************************************************/
61 #ifndef _PQ_STATEMENT_HXX_
62 #define _PQ_STATEMENT_HXX_
63 #include <cppuhelper/propshlp.hxx>
64 #include <cppuhelper/component.hxx>
66 #include <libpq-fe.h>
68 #include "pq_connection.hxx"
69 #include <com/sun/star/sdbc/XMultipleResults.hpp>
70 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
71 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
73 namespace pq_sdbc_driver
76 static const sal_Int32 STATEMENT_CURSOR_NAME = 0;
77 static const sal_Int32 STATEMENT_ESCAPE_PROCESSING = 1;
78 static const sal_Int32 STATEMENT_FETCH_DIRECTION = 2;
79 static const sal_Int32 STATEMENT_FETCH_SIZE = 3;
80 static const sal_Int32 STATEMENT_MAX_FIELD_SIZE = 4;
81 static const sal_Int32 STATEMENT_MAX_ROWS = 5;
82 static const sal_Int32 STATEMENT_QUERY_TIME_OUT = 6;
83 static const sal_Int32 STATEMENT_RESULT_SET_CONCURRENCY = 7;
84 static const sal_Int32 STATEMENT_RESULT_SET_TYPE = 8;
86 #define STATEMENT_SIZE 9
87 class ResultSet;
89 class Statement : public cppu::OComponentHelper,
90 public cppu::OPropertySetHelper,
91 public com::sun::star::sdbc::XStatement,
92 public com::sun::star::sdbc::XCloseable,
93 public com::sun::star::sdbc::XWarningsSupplier,
94 public com::sun::star::sdbc::XMultipleResults,
95 public com::sun::star::sdbc::XGeneratedResultSet,
96 public com::sun::star::sdbc::XResultSetMetaDataSupplier
98 private:
99 com::sun::star::uno::Any m_props[STATEMENT_SIZE];
100 com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
101 ConnectionSettings *m_pSettings;
102 com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > m_lastResultset;
103 ::rtl::Reference< RefCountedMutex > m_refMutex;
104 sal_Bool m_multipleResultAvailable;
105 sal_Int32 m_multipleResultUpdateCount;
106 sal_Int32 m_lastOidInserted;
107 rtl::OUString m_lastTableInserted;
108 rtl::OString m_lastQuery;
110 public:
112 * @param ppConnection The piece of memory, pConnection points to, is accessisble
113 * as long as a reference to paramenter con is held.
115 Statement( const rtl::Reference< RefCountedMutex > & refMutex,
116 const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection> & con,
117 struct ConnectionSettings *pSettings );
119 virtual ~Statement();
120 public: // XInterface
121 virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
122 virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
123 virtual com::sun::star::uno::Any SAL_CALL queryInterface( const com::sun::star::uno::Type & reqType )
124 throw (com::sun::star::uno::RuntimeException);
126 public: // XCloseable
127 virtual void SAL_CALL close( )
128 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
130 public: // XStatement
131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
132 const ::rtl::OUString& sql )
133 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
134 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql )
135 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
136 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql )
137 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( )
139 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
141 public: // XWarningsSupplier
142 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( )
143 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
144 virtual void SAL_CALL clearWarnings( )
145 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
147 public: // XTypeProvider, first implemented by OPropertySetHelper
148 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
149 throw( com::sun::star::uno::RuntimeException );
150 virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
151 throw( com::sun::star::uno::RuntimeException );
153 public: // OPropertySetHelper
154 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
156 virtual sal_Bool SAL_CALL convertFastPropertyValue(
157 ::com::sun::star::uno::Any & rConvertedValue,
158 ::com::sun::star::uno::Any & rOldValue,
159 sal_Int32 nHandle,
160 const ::com::sun::star::uno::Any& rValue )
161 throw (::com::sun::star::lang::IllegalArgumentException);
163 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
164 sal_Int32 nHandle,
165 const ::com::sun::star::uno::Any& rValue )
166 throw (::com::sun::star::uno::Exception);
168 virtual void SAL_CALL getFastPropertyValue(
169 ::com::sun::star::uno::Any& rValue,
170 sal_Int32 nHandle ) const;
172 // XPropertySet
173 ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
174 throw(com::sun::star::uno::RuntimeException);
176 public: // XGeneratedResultSet
177 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
178 getGeneratedValues( )
179 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
181 public: // XMultipleResults
182 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( )
183 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
184 virtual sal_Int32 SAL_CALL getUpdateCount( )
185 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
186 virtual sal_Bool SAL_CALL getMoreResults( )
187 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
189 public: // OComponentHelper
190 virtual void SAL_CALL disposing();
192 public: // XResultSetMetaDataSupplier (is required by framework (see
193 // dbaccess/source/core/api/preparedstatement.cxx::getMetaData() )
194 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
195 throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
197 private:
198 void checkClosed() throw (com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException);
199 void raiseSQLException( const ::rtl::OUString & sql, const char * errorMsg, const char *errorType = 0 )
200 throw ( com::sun::star::sdbc::SQLException );
204 struct CommandData
206 ConnectionSettings **ppSettings;
207 sal_Int32 *pLastOidInserted;
208 sal_Int32 *pMultipleResultUpdateCount;
209 sal_Bool *pMultipleResultAvailable;
210 ::rtl::OUString *pLastTableInserted;
211 ::com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > *pLastResultset;
212 ::rtl::OString *pLastQuery;
213 ::rtl::Reference< RefCountedMutex > refMutex;
214 ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > owner;
215 ::com::sun::star::uno::Reference< com::sun::star::sdbcx::XTablesSupplier > tableSupplier;
216 sal_Int32 concurrency;
219 bool executePostgresCommand( const rtl::OString & cmd, struct CommandData *data );
220 com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
221 ConnectionSettings *pConnectionSettings,
222 const com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > &connection,
223 sal_Int32 nLastOid,
224 const rtl::OUString & lastTableInserted,
225 const rtl::OString & lastQuery );
229 #endif