Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / firebird / PreparedStatement.hxx
blob252037307cbb7d7152b2ae8997181f4ed9e34500
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_PREPAREDSTATEMENT_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_PREPAREDSTATEMENT_HXX
23 #include "Statement.hxx"
25 #include <cppuhelper/implbase5.hxx>
27 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
28 #include <com/sun/star/sdbc/XParameters.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
30 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
31 #include <com/sun/star/io/XInputStream.hpp>
33 #include <ibase.h>
35 namespace connectivity
37 namespace firebird
40 class OBoundParam;
41 typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
42 ::com::sun::star::sdbc::XParameters,
43 ::com::sun::star::sdbc::XPreparedBatchExecution,
44 ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
45 ::com::sun::star::lang::XServiceInfo> OPreparedStatement_Base;
47 class OPreparedStatement : public OStatementCommonBase,
48 public OPreparedStatement_Base
50 protected:
51 struct Parameter
53 ::com::sun::star::uno::Any aValue;
54 sal_Int32 nDataType;
56 Parameter(const ::com::sun::star::uno::Any& rValue,
57 sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType)
63 ::std::vector< Parameter> m_aParameters;
65 TTypeInfoVector m_aTypeInfo; // Hashtable containing an entry
66 // for each row returned by
67 // DatabaseMetaData.getTypeInfo.
69 ::rtl::OUString m_sSqlStatement;
70 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
72 XSQLDA* m_pOutSqlda;
73 XSQLDA* m_pInSqlda;
74 void checkParameterIndex(sal_Int32 nParameterIndex)
75 throw(::com::sun::star::sdbc::SQLException,
76 ::com::sun::star::uno::RuntimeException);
78 /**
79 * Set a numeric value in the input SQLDA. If the destination
80 * parameter is not of nType then an Exception will be thrown.
82 template <typename T> void setValue(sal_Int32 nIndex, T& nValue, ISC_SHORT nType)
83 throw(::com::sun::star::sdbc::SQLException,
84 ::com::sun::star::uno::RuntimeException);
85 void setParameterNull(sal_Int32 nParameterIndex, bool bSetNull = true);
87 void ensurePrepared()
88 throw(::com::sun::star::sdbc::SQLException,
89 ::com::sun::star::uno::RuntimeException);
90 /**
91 * Assumes that all necessary mutexes have been taken.
93 void openBlobForWriting(isc_blob_handle& rBlobHandle, ISC_QUAD& rBlobId);
94 /**
95 * Assumes that all necessary mutexes have been taken.
97 void closeBlobAfterWriting(isc_blob_handle& rBlobHandle);
99 protected:
100 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
101 const ::com::sun::star::uno::Any& rValue)
102 throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
103 virtual ~OPreparedStatement();
104 public:
105 DECLARE_SERVICE_INFO();
106 // a constructor, which is required for returning objects:
107 OPreparedStatement( Connection* _pConnection,
108 const TTypeInfoVector& _TypeInfo,
109 const ::rtl::OUString& sql);
111 //XInterface
112 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
114 virtual void SAL_CALL release() throw() SAL_OVERRIDE;
115 //XTypeProvider
116 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 // XPreparedStatement
119 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL
120 executeQuery()
121 throw(::com::sun::star::sdbc::SQLException,
122 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 virtual sal_Int32 SAL_CALL
124 executeUpdate()
125 throw(::com::sun::star::sdbc::SQLException,
126 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 virtual sal_Bool SAL_CALL
128 execute()
129 throw(::com::sun::star::sdbc::SQLException,
130 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL
132 getConnection()
133 throw(::com::sun::star::sdbc::SQLException,
134 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 // XParameters
137 virtual void SAL_CALL setNull(sal_Int32 nIndex, sal_Int32 nValue)
138 throw(::com::sun::star::sdbc::SQLException,
139 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 virtual void SAL_CALL setBoolean( sal_Int32 nIndex, sal_Bool nValue)
142 throw(::com::sun::star::sdbc::SQLException,
143 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 virtual void SAL_CALL setByte(sal_Int32 nIndex, sal_Int8 nValue)
145 throw(::com::sun::star::sdbc::SQLException,
146 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 virtual void SAL_CALL setShort(sal_Int32 nIndex, sal_Int16 nValue)
148 throw(::com::sun::star::sdbc::SQLException,
149 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 virtual void SAL_CALL setInt(sal_Int32 nIndex, sal_Int32 nValue)
151 throw(::com::sun::star::sdbc::SQLException,
152 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 virtual void SAL_CALL setLong(sal_Int32 nIndex, sal_Int64 nValue)
154 throw(::com::sun::star::sdbc::SQLException,
155 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
167 virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 // XPreparedBatchExecution -- UNSUPPORTED by firebird
174 virtual void SAL_CALL
175 addBatch()
176 throw(::com::sun::star::sdbc::SQLException,
177 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 virtual void SAL_CALL
179 clearBatch()
180 throw(::com::sun::star::sdbc::SQLException,
181 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
183 executeBatch()
184 throw(::com::sun::star::sdbc::SQLException,
185 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 // XCloseable
188 virtual void SAL_CALL close()
189 throw(::com::sun::star::sdbc::SQLException,
190 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 // OComponentHelper
192 virtual void SAL_CALL disposing() SAL_OVERRIDE;
194 // XResultSetMetaDataSupplier
195 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_FIREBIRD_PREPAREDSTATEMENT_HXX
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */