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