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
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "ado/ACallableStatement.hxx"
27 #include <connectivity/dbexception.hxx>
28
29 using namespace connectivity::ado;
30 using namespace com::sun::star::uno;
31 using namespace com::sun::star::lang;
32 using namespace com::sun::star::beans;
33 using namespace com::sun::star::sdbc;
34 using namespace com::sun::star::container;
35 using namespace com::sun::star::lang;
36
37 IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
38
39 #define GET_PARAM() \
40 ADOParameter* pParam = NULL; \
41 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam); \
42 if(pParam) \
43 pParam->get_Value(&m_aValue);
44 //**************************************************************
45 //************ Class: java.sql.CallableStatement
46 //**************************************************************
OCallableStatement(OConnection * _pConnection,const OTypeInfoMap & _TypeInfo,const::rtl::OUString & sql)47 OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql )
48 : OPreparedStatement( _pConnection, _TypeInfo, sql )
49 {
50 m_Command.put_CommandType(adCmdStoredProc);
51 }
52 // -------------------------------------------------------------------------
53
queryInterface(const Type & rType)54 Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
55 {
56 Any aRet = OPreparedStatement::queryInterface(rType);
57 return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
58 }
59 // -------------------------------------------------------------------------
60
61
wasNull()62 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
63 {
64 return m_aValue.isNull();
65 }
66 // -------------------------------------------------------------------------
67
getBoolean(sal_Int32 columnIndex)68 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
69 {
70 GET_PARAM()
71 return m_aValue;
72 }
73 // -------------------------------------------------------------------------
getByte(sal_Int32 columnIndex)74 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
75 {
76 GET_PARAM()
77 return m_aValue;
78 }
79 // -------------------------------------------------------------------------
getBytes(sal_Int32 columnIndex)80 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
81 {
82 GET_PARAM()
83 return m_aValue;
84 }
85 // -------------------------------------------------------------------------
getDate(sal_Int32 columnIndex)86 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
87 {
88 GET_PARAM()
89 return m_aValue;
90 }
91 // -------------------------------------------------------------------------
getDouble(sal_Int32 columnIndex)92 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
93 {
94 GET_PARAM()
95 return m_aValue;
96 }
97 // -------------------------------------------------------------------------
98
getFloat(sal_Int32 columnIndex)99 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
100 {
101 GET_PARAM()
102 return m_aValue;
103 }
104 // -------------------------------------------------------------------------
105
getInt(sal_Int32 columnIndex)106 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
107 {
108 GET_PARAM()
109 return m_aValue;
110 }
111 // -------------------------------------------------------------------------
112
getLong(sal_Int32 columnIndex)113 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
114 {
115 GET_PARAM()
116 return (sal_Int64)m_aValue.getCurrency().int64;
117 }
118 // -------------------------------------------------------------------------
119
getObject(sal_Int32,const Reference<::com::sun::star::container::XNameAccess> &)120 Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
121 {
122 ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
123 return Any();
124 }
125 // -------------------------------------------------------------------------
126
getShort(sal_Int32 columnIndex)127 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
128 {
129 GET_PARAM()
130 return m_aValue;
131 }
132 // -------------------------------------------------------------------------
133
getString(sal_Int32 columnIndex)134 ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
135 {
136 GET_PARAM()
137 return m_aValue;
138 }
139 // -------------------------------------------------------------------------
140
getTime(sal_Int32 columnIndex)141 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
142 {
143 GET_PARAM()
144 return m_aValue;
145 }
146 // -------------------------------------------------------------------------
147
getTimestamp(sal_Int32 columnIndex)148 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
149 {
150 GET_PARAM()
151 return m_aValue;
152 }
153 // -------------------------------------------------------------------------
154
registerOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,const::rtl::OUString &)155 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
156 {
157 ADOParameter* pParam = NULL;
158 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
159 if(pParam)
160 {
161 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
162 pParam->put_Direction(adParamOutput);
163 }
164 }
165 // -------------------------------------------------------------------------
registerNumericOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,sal_Int32 scale)166 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
167 {
168 ADOParameter* pParam = NULL;
169 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
170 if(pParam)
171 {
172 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
173 pParam->put_Direction(adParamOutput);
174 pParam->put_NumericScale((sal_Int8)scale);
175 }
176 }
177 // -------------------------------------------------------------------------
178
179
getBinaryStream(sal_Int32)180 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
181 {
182 ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
183 return NULL;
184 }
185 // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)186 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
187 {
188 ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
189 return NULL;
190 }
191 // -------------------------------------------------------------------------
192
getArray(sal_Int32)193 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
194 {
195 ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
196 return NULL;
197 }
198 // -------------------------------------------------------------------------
199
getClob(sal_Int32)200 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
201 {
202 ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
203 return NULL;
204 }
205 // -------------------------------------------------------------------------
getBlob(sal_Int32)206 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
207 {
208 ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
209 return NULL;
210 }
211 // -------------------------------------------------------------------------
212
getRef(sal_Int32)213 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
214 {
215 ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
216 return NULL;
217 }
218 // -------------------------------------------------------------------------
219 // -----------------------------------------------------------------------------
acquire()220 void SAL_CALL OCallableStatement::acquire() throw()
221 {
222 OPreparedStatement::acquire();
223 }
224 // -----------------------------------------------------------------------------
release()225 void SAL_CALL OCallableStatement::release() throw()
226 {
227 OPreparedStatement::release();
228 }
229 // -----------------------------------------------------------------------------
230
231
232