update dev300-m58
[ooovba.git] / connectivity / source / inc / odbc / OStatement.hxx
blob4e3547e79b2cb7f72bc938589ec1d563463c1062
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OStatement.hxx,v $
10 * $Revision: 1.25 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_ODBC_OSTATEMENT_HXX_
32 #define _CONNECTIVITY_ODBC_OSTATEMENT_HXX_
34 #include <com/sun/star/sdbc/XStatement.hpp>
35 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
36 #include <com/sun/star/sdbc/XMultipleResults.hpp>
37 #include <com/sun/star/sdbc/XBatchExecution.hpp>
38 #include <com/sun/star/sdbc/XCloseable.hpp>
39 #include <com/sun/star/sdbc/SQLWarning.hpp>
40 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
41 #include <com/sun/star/util/XCancellable.hpp>
42 #include <comphelper/proparrhlp.hxx>
43 #include <cppuhelper/compbase6.hxx>
44 #include <comphelper/uno3.hxx>
45 #include "connectivity/CommonTools.hxx"
46 #include "odbc/OFunctions.hxx"
47 #include "odbc/OConnection.hxx"
48 #include "odbc/odbcbasedllapi.hxx"
49 #include <list>
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #include <comphelper/broadcasthelper.hxx>
53 namespace connectivity
55 namespace odbc
58 typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::sdbc::XStatement,
59 ::com::sun::star::sdbc::XWarningsSupplier,
60 ::com::sun::star::util::XCancellable,
61 ::com::sun::star::sdbc::XCloseable,
62 ::com::sun::star::sdbc::XGeneratedResultSet,
63 ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
65 class OResultSet;
66 //**************************************************************
67 //************ Class: java.sql.Statement
68 //**************************************************************
69 class OOO_DLLPUBLIC_ODBCBASE OStatement_Base :
70 public comphelper::OBaseMutex,
71 public OStatement_BASE,
72 public ::cppu::OPropertySetHelper,
73 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
76 ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
77 protected:
78 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
79 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> m_xGeneratedStatement;
80 // for this Statement
82 ::std::list< ::rtl::OUString> m_aBatchList;
83 ::rtl::OUString m_sSqlStatement;
85 OConnection* m_pConnection;// The owning Connection object
86 SQLHANDLE m_aStatementHandle;
87 SQLUSMALLINT* m_pRowStatusArray;
88 ::cppu::OBroadcastHelper& rBHelper;
90 protected:
92 sal_Int32 getQueryTimeOut() const;
93 sal_Int32 getMaxFieldSize() const;
94 sal_Int32 getMaxRows() const;
95 sal_Int32 getResultSetConcurrency() const;
96 sal_Int32 getResultSetType() const;
97 sal_Int32 getFetchDirection() const;
98 sal_Int32 getFetchSize() const;
99 ::rtl::OUString getCursorName() const;
100 sal_Bool isUsingBookmarks() const;
101 sal_Bool getEscapeProcessing() const;
102 sal_Int32 getStmtOption (short fOption) const;
104 void setQueryTimeOut(sal_Int32 _par0) ;
105 void setMaxFieldSize(sal_Int32 _par0) ;
106 void setMaxRows(sal_Int32 _par0) ;
107 void setFetchDirection(sal_Int32 _par0) ;
108 void setFetchSize(sal_Int32 _par0) ;
109 void setCursorName(const ::rtl::OUString &_par0);
110 void setEscapeProcessing( const sal_Bool _bEscapeProc );
112 virtual void setResultSetConcurrency(sal_Int32 _par0) ;
113 virtual void setResultSetType(sal_Int32 _par0) ;
114 virtual void setUsingBookmarks(sal_Bool _bUseBookmark) ;
116 void reset () throw( ::com::sun::star::sdbc::SQLException);
117 void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
118 void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException);
119 sal_Bool lockIfNecessary (const ::rtl::OUString& sql) throw( ::com::sun::star::sdbc::SQLException);
120 sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException);
122 //--------------------------------------------------------------------
123 // getResultSet
124 // getResultSet returns the current result as a ResultSet. It
125 // returns NULL if the current result is not a ResultSet.
126 //--------------------------------------------------------------------
127 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > getResultSet (sal_Bool checkCount) throw( ::com::sun::star::sdbc::SQLException);
129 creates the driver specific resultset (factory)
131 virtual OResultSet* createResulSet();
133 SQLLEN getRowCount () throw( ::com::sun::star::sdbc::SQLException);
136 void disposeResultSet();
138 // OPropertyArrayUsageHelper
139 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
140 // OPropertySetHelper
141 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
142 virtual sal_Bool SAL_CALL convertFastPropertyValue(
143 ::com::sun::star::uno::Any & rConvertedValue,
144 ::com::sun::star::uno::Any & rOldValue,
145 sal_Int32 nHandle,
146 const ::com::sun::star::uno::Any& rValue )
147 throw (::com::sun::star::lang::IllegalArgumentException);
148 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
149 sal_Int32 nHandle,
150 const ::com::sun::star::uno::Any& rValue
152 throw (::com::sun::star::uno::Exception);
153 virtual void SAL_CALL getFastPropertyValue(
154 ::com::sun::star::uno::Any& rValue,
155 sal_Int32 nHandle
156 ) const;
157 virtual ~OStatement_Base();
159 public:
160 OStatement_Base(OConnection* _pConnection );
161 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
163 inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
165 return m_pConnection->getOdbcFunction(_nIndex);
167 // OComponentHelper
168 virtual void SAL_CALL disposing(void);
169 // XInterface
170 virtual void SAL_CALL release() throw();
171 virtual void SAL_CALL acquire() throw();
172 // XInterface
173 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
174 //XTypeProvider
175 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
177 // XPropertySet
178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
179 // XStatement
180 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
181 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
182 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
183 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
184 // XWarningsSupplier
185 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
186 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
187 // XCancellable
188 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
189 // XCloseable
190 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
191 // XMultipleResults
192 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
193 virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
194 virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
195 //XGeneratedResultSet
196 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
198 // other methods
199 SQLHANDLE getConnectionHandle() { return m_pConnection->getConnection(); }
200 OConnection* getOwnConnection() const { return m_pConnection;}
201 /** getCursorProperties return the properties for a specific cursor type
202 @param _nCursorType the CursorType
203 @param bFirst when true the first property set is returned
205 @return the cursor properties
207 SQLUINTEGER getCursorProperties(SQLINTEGER _nCursorType,sal_Bool bFirst);
209 protected:
210 using OPropertySetHelper::getFastPropertyValue;
213 class OOO_DLLPUBLIC_ODBCBASE OStatement_BASE2 :
214 public OStatement_Base
215 ,public ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>
218 friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
219 public:
220 OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
221 ::connectivity::OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
222 // OComponentHelper
223 virtual void SAL_CALL disposing(void);
224 // XInterface
225 virtual void SAL_CALL release() throw();
228 class OOO_DLLPUBLIC_ODBCBASE OStatement :
229 public OStatement_BASE2,
230 public ::com::sun::star::sdbc::XBatchExecution,
231 public ::com::sun::star::lang::XServiceInfo
233 protected:
234 virtual ~OStatement(){}
235 public:
236 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
237 OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
238 DECLARE_SERVICE_INFO();
240 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
241 virtual void SAL_CALL acquire() throw();
242 virtual void SAL_CALL release() throw();
243 // XBatchExecution
244 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
245 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
246 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
250 #endif // _CONNECTIVITY_ODBC_OSTATEMENT_HXX_