1*079eb577SAndrew Rist /**************************************************************
2*079eb577SAndrew Rist  *
3*079eb577SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*079eb577SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*079eb577SAndrew Rist  * distributed with this work for additional information
6*079eb577SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*079eb577SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*079eb577SAndrew Rist  * "License"); you may not use this file except in compliance
9*079eb577SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*079eb577SAndrew Rist  *
11*079eb577SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*079eb577SAndrew Rist  *
13*079eb577SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*079eb577SAndrew Rist  * software distributed under the License is distributed on an
15*079eb577SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*079eb577SAndrew Rist  * KIND, either express or implied.  See the License for the
17*079eb577SAndrew Rist  * specific language governing permissions and limitations
18*079eb577SAndrew Rist  * under the License.
19*079eb577SAndrew Rist  *
20*079eb577SAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #ifndef CONNECTIVITY_SPREPAREDSTATEMENT_HXX
23cdf0e10cSrcweir #define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
24cdf0e10cSrcweir #include "mysqlc_statement.hxx"
25cdf0e10cSrcweir #include "mysqlc_resultset.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedStatement.hpp>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XParameters.hpp>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_
37cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
40cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <preextstl.h>
44cdf0e10cSrcweir #include <cppconn/prepared_statement.h>
45cdf0e10cSrcweir #include <postextstl.h>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace connectivity
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	namespace mysqlc
50cdf0e10cSrcweir 	{
51cdf0e10cSrcweir 		using ::com::sun::star::uno::Reference;
52cdf0e10cSrcweir 		using ::com::sun::star::uno::Any;
53cdf0e10cSrcweir 		using ::com::sun::star::uno::Type;
54cdf0e10cSrcweir 		using ::com::sun::star::sdbc::SQLException;
55cdf0e10cSrcweir 		using ::com::sun::star::uno::RuntimeException;
56cdf0e10cSrcweir 		using ::com::sun::star::sdbc::XResultSetMetaData;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 		class OBoundParam;
59cdf0e10cSrcweir 		typedef ::cppu::ImplHelper5<	::com::sun::star::sdbc::XPreparedStatement,
60cdf0e10cSrcweir 										::com::sun::star::sdbc::XParameters,
61cdf0e10cSrcweir 										::com::sun::star::sdbc::XPreparedBatchExecution,
62cdf0e10cSrcweir 										::com::sun::star::sdbc::XResultSetMetaDataSupplier,
63cdf0e10cSrcweir 										::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		class OPreparedStatement :	public OCommonStatement,
66cdf0e10cSrcweir 									public OPreparedStatement_BASE
67cdf0e10cSrcweir 		{
68cdf0e10cSrcweir 		protected:
69cdf0e10cSrcweir 			unsigned int		m_paramCount;	// number of placeholders
70cdf0e10cSrcweir 			sal_Int32			m_nNumParams;	// Number of parameter markers for the prepared statement
71cdf0e10cSrcweir 			Reference< XResultSetMetaData > m_xMetaData;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 			void checkParameterIndex(sal_Int32 parameter);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 		protected:
76cdf0e10cSrcweir 			void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
77cdf0e10cSrcweir 																					throw (::com::sun::star::uno::Exception);
78cdf0e10cSrcweir 			virtual ~OPreparedStatement();
79cdf0e10cSrcweir 		public:
80cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
81cdf0e10cSrcweir 			OPreparedStatement(OConnection* _pConnection, sql::PreparedStatement * cppPrepStmt);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 			//XInterface
84cdf0e10cSrcweir 			Any SAL_CALL queryInterface(const Type & rType)	throw(RuntimeException);
85cdf0e10cSrcweir 			void SAL_CALL acquire() throw();
86cdf0e10cSrcweir 			void SAL_CALL release() throw();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 			//XTypeProvider
89cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< Type > SAL_CALL getTypes()
90cdf0e10cSrcweir 																					throw(RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 			// XPreparedStatement
93cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery()	throw(SQLException, RuntimeException);
94cdf0e10cSrcweir 			sal_Int32 SAL_CALL executeUpdate() throw(SQLException, RuntimeException);
95cdf0e10cSrcweir 			sal_Bool SAL_CALL execute() throw(SQLException, RuntimeException);
96cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection() throw(SQLException, RuntimeException);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir             // XStatement
99cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
100cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
101cdf0e10cSrcweir 			sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
102cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
103cdf0e10cSrcweir 			sal_Bool SAL_CALL execute( const OUString& sql )
104cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 			// XParameters
107cdf0e10cSrcweir 			void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType)			throw(SQLException, RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 			void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const OUString& typeName)
110cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 			void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x)				throw(SQLException, RuntimeException);
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 			void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x)					throw(SQLException, RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 			void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x)				throw(SQLException, RuntimeException);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 			void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x)					throw(SQLException, RuntimeException);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 			void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x)					throw(SQLException, RuntimeException);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 			void SAL_CALL setFloat(sal_Int32 parameter, float x)					throw(SQLException, RuntimeException);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 			void SAL_CALL setDouble(sal_Int32 parameter, double x)					throw(SQLException, RuntimeException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 			void SAL_CALL setString(sal_Int32 parameter, const OUString& x)			throw(SQLException, RuntimeException);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 			void SAL_CALL setBytes(sal_Int32 parameter, const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
129cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			void SAL_CALL setDate(sal_Int32 parameter, const ::com::sun::star::util::Date& x)
132cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 			void SAL_CALL setTime(sal_Int32 parameter, const ::com::sun::star::util::Time& x)
135cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
136cdf0e10cSrcweir 			void SAL_CALL setTimestamp(sal_Int32 parameter, const ::com::sun::star::util::DateTime& x)
137cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 			void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
140cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 			void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
143cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 			void SAL_CALL setObject(sal_Int32 parameter, const Any& x)				throw(SQLException, RuntimeException);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 			void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale)
148cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 			void SAL_CALL setRef(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XRef >& x)
151cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 			void SAL_CALL setBlob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XBlob >& x)
154cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 			void SAL_CALL setClob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XClob >& x)
157cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 			void SAL_CALL setArray(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XArray >& x)
160cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 			void SAL_CALL clearParameters() throw(SQLException, RuntimeException);
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 			// XPreparedBatchExecution
165cdf0e10cSrcweir 			void SAL_CALL addBatch() throw(SQLException, RuntimeException);
166cdf0e10cSrcweir 			void SAL_CALL clearBatch() throw(SQLException, RuntimeException);
167cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()	throw(SQLException, RuntimeException);
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 			// XCloseable
170cdf0e10cSrcweir 			void SAL_CALL close() throw(SQLException, RuntimeException);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 			// XResultSetMetaDataSupplier
173cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData()
174cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
175cdf0e10cSrcweir 		};
176cdf0e10cSrcweir 	} /* mysqlc */
177cdf0e10cSrcweir } /* connectivity */
178cdf0e10cSrcweir #endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
179cdf0e10cSrcweir 
180cdf0e10cSrcweir /*
181cdf0e10cSrcweir  * Local variables:
182cdf0e10cSrcweir  * tab-width: 4
183cdf0e10cSrcweir  * c-basic-offset: 4
184cdf0e10cSrcweir  * End:
185cdf0e10cSrcweir  * vim600: noet sw=4 ts=4 fdm=marker
186cdf0e10cSrcweir  * vim<600: noet sw=4 ts=4
187cdf0e10cSrcweir  */
188cdf0e10cSrcweir 
189