1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*cdf0e10cSrcweir *
4*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc.
5*cdf0e10cSrcweir *
6*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
7*cdf0e10cSrcweir *
8*cdf0e10cSrcweir * $RCSfile: mysqlc_preparedstatement.hxx,v $
9*cdf0e10cSrcweir *
10*cdf0e10cSrcweir * $Revision: 1.1.2.4 $
11*cdf0e10cSrcweir *
12*cdf0e10cSrcweir * This file is part of OpenOffice.org.
13*cdf0e10cSrcweir *
14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
16*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
17*cdf0e10cSrcweir *
18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
23*cdf0e10cSrcweir *
24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
25*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
27*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
28*cdf0e10cSrcweir ************************************************************************/
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #ifndef CONNECTIVITY_SPREPAREDSTATEMENT_HXX
31*cdf0e10cSrcweir #define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
32*cdf0e10cSrcweir #include "mysqlc_statement.hxx"
33*cdf0e10cSrcweir #include "mysqlc_resultset.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
36*cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedStatement.hpp>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
39*cdf0e10cSrcweir #include <com/sun/star/sdbc/XParameters.hpp>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
42*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_
45*cdf0e10cSrcweir #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
48*cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #include <preextstl.h>
52*cdf0e10cSrcweir #include <cppconn/prepared_statement.h>
53*cdf0e10cSrcweir #include <postextstl.h>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir namespace connectivity
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir 	namespace mysqlc
58*cdf0e10cSrcweir 	{
59*cdf0e10cSrcweir 		using ::com::sun::star::uno::Reference;
60*cdf0e10cSrcweir 		using ::com::sun::star::uno::Any;
61*cdf0e10cSrcweir 		using ::com::sun::star::uno::Type;
62*cdf0e10cSrcweir 		using ::com::sun::star::sdbc::SQLException;
63*cdf0e10cSrcweir 		using ::com::sun::star::uno::RuntimeException;
64*cdf0e10cSrcweir 		using ::com::sun::star::sdbc::XResultSetMetaData;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir 		class OBoundParam;
67*cdf0e10cSrcweir 		typedef ::cppu::ImplHelper5<	::com::sun::star::sdbc::XPreparedStatement,
68*cdf0e10cSrcweir 										::com::sun::star::sdbc::XParameters,
69*cdf0e10cSrcweir 										::com::sun::star::sdbc::XPreparedBatchExecution,
70*cdf0e10cSrcweir 										::com::sun::star::sdbc::XResultSetMetaDataSupplier,
71*cdf0e10cSrcweir 										::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 		class OPreparedStatement :	public OCommonStatement,
74*cdf0e10cSrcweir 									public OPreparedStatement_BASE
75*cdf0e10cSrcweir 		{
76*cdf0e10cSrcweir 		protected:
77*cdf0e10cSrcweir 			unsigned int		m_paramCount;	// number of placeholders
78*cdf0e10cSrcweir 			sal_Int32			m_nNumParams;	// Number of parameter markers for the prepared statement
79*cdf0e10cSrcweir 			Reference< XResultSetMetaData > m_xMetaData;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 			void checkParameterIndex(sal_Int32 parameter);
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir 		protected:
84*cdf0e10cSrcweir 			void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
85*cdf0e10cSrcweir 																					throw (::com::sun::star::uno::Exception);
86*cdf0e10cSrcweir 			virtual ~OPreparedStatement();
87*cdf0e10cSrcweir 		public:
88*cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
89*cdf0e10cSrcweir 			OPreparedStatement(OConnection* _pConnection, sql::PreparedStatement * cppPrepStmt);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 			//XInterface
92*cdf0e10cSrcweir 			Any SAL_CALL queryInterface(const Type & rType)	throw(RuntimeException);
93*cdf0e10cSrcweir 			void SAL_CALL acquire() throw();
94*cdf0e10cSrcweir 			void SAL_CALL release() throw();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 			//XTypeProvider
97*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< Type > SAL_CALL getTypes()
98*cdf0e10cSrcweir 																					throw(RuntimeException);
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 			// XPreparedStatement
101*cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery()	throw(SQLException, RuntimeException);
102*cdf0e10cSrcweir 			sal_Int32 SAL_CALL executeUpdate() throw(SQLException, RuntimeException);
103*cdf0e10cSrcweir 			sal_Bool SAL_CALL execute() throw(SQLException, RuntimeException);
104*cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection() throw(SQLException, RuntimeException);
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir             // XStatement
107*cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
108*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
109*cdf0e10cSrcweir 			sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
110*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
111*cdf0e10cSrcweir 			sal_Bool SAL_CALL execute( const OUString& sql )
112*cdf0e10cSrcweir 												throw(SQLException, RuntimeException);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 			// XParameters
115*cdf0e10cSrcweir 			void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType)			throw(SQLException, RuntimeException);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 			void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const OUString& typeName)
118*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 			void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x)				throw(SQLException, RuntimeException);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir 			void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x)					throw(SQLException, RuntimeException);
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 			void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x)				throw(SQLException, RuntimeException);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 			void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x)					throw(SQLException, RuntimeException);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 			void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x)					throw(SQLException, RuntimeException);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 			void SAL_CALL setFloat(sal_Int32 parameter, float x)					throw(SQLException, RuntimeException);
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 			void SAL_CALL setDouble(sal_Int32 parameter, double x)					throw(SQLException, RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 			void SAL_CALL setString(sal_Int32 parameter, const OUString& x)			throw(SQLException, RuntimeException);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 			void SAL_CALL setBytes(sal_Int32 parameter, const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
137*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 			void SAL_CALL setDate(sal_Int32 parameter, const ::com::sun::star::util::Date& x)
140*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 			void SAL_CALL setTime(sal_Int32 parameter, const ::com::sun::star::util::Time& x)
143*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
144*cdf0e10cSrcweir 			void SAL_CALL setTimestamp(sal_Int32 parameter, const ::com::sun::star::util::DateTime& x)
145*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 			void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
148*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 			void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
151*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 			void SAL_CALL setObject(sal_Int32 parameter, const Any& x)				throw(SQLException, RuntimeException);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 			void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale)
156*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 			void SAL_CALL setRef(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XRef >& x)
159*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 			void SAL_CALL setBlob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XBlob >& x)
162*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 			void SAL_CALL setClob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XClob >& x)
165*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 			void SAL_CALL setArray(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XArray >& x)
168*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 			void SAL_CALL clearParameters() throw(SQLException, RuntimeException);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 			// XPreparedBatchExecution
173*cdf0e10cSrcweir 			void SAL_CALL addBatch() throw(SQLException, RuntimeException);
174*cdf0e10cSrcweir 			void SAL_CALL clearBatch() throw(SQLException, RuntimeException);
175*cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()	throw(SQLException, RuntimeException);
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 			// XCloseable
178*cdf0e10cSrcweir 			void SAL_CALL close() throw(SQLException, RuntimeException);
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 			// XResultSetMetaDataSupplier
181*cdf0e10cSrcweir 			Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData()
182*cdf0e10cSrcweir 																					throw(SQLException, RuntimeException);
183*cdf0e10cSrcweir 		};
184*cdf0e10cSrcweir 	} /* mysqlc */
185*cdf0e10cSrcweir } /* connectivity */
186*cdf0e10cSrcweir #endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir /*
189*cdf0e10cSrcweir  * Local variables:
190*cdf0e10cSrcweir  * tab-width: 4
191*cdf0e10cSrcweir  * c-basic-offset: 4
192*cdf0e10cSrcweir  * End:
193*cdf0e10cSrcweir  * vim600: noet sw=4 ts=4 fdm=marker
194*cdf0e10cSrcweir  * vim<600: noet sw=4 ts=4
195*cdf0e10cSrcweir  */
196*cdf0e10cSrcweir 
197