1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "ado/ACallableStatement.hxx"
27cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir using namespace connectivity::ado;
30cdf0e10cSrcweir using namespace com::sun::star::uno;
31cdf0e10cSrcweir using namespace com::sun::star::lang;
32cdf0e10cSrcweir using namespace com::sun::star::beans;
33cdf0e10cSrcweir using namespace com::sun::star::sdbc;
34cdf0e10cSrcweir using namespace com::sun::star::container;
35cdf0e10cSrcweir using namespace com::sun::star::lang;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #define GET_PARAM()													\
40cdf0e10cSrcweir 	ADOParameter* pParam = NULL;									\
41cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);		\
42cdf0e10cSrcweir 	if(pParam)														\
43cdf0e10cSrcweir 		pParam->get_Value(&m_aValue);
44cdf0e10cSrcweir //**************************************************************
45cdf0e10cSrcweir //************ Class: java.sql.CallableStatement
46cdf0e10cSrcweir //**************************************************************
OCallableStatement(OConnection * _pConnection,const OTypeInfoMap & _TypeInfo,const::rtl::OUString & sql)47cdf0e10cSrcweir OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql )
48cdf0e10cSrcweir 				: OPreparedStatement( _pConnection, _TypeInfo, sql )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	m_Command.put_CommandType(adCmdStoredProc);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir // -------------------------------------------------------------------------
53cdf0e10cSrcweir 
queryInterface(const Type & rType)54cdf0e10cSrcweir Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir 	Any aRet = OPreparedStatement::queryInterface(rType);
57cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
58cdf0e10cSrcweir }
59cdf0e10cSrcweir // -------------------------------------------------------------------------
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
wasNull()62cdf0e10cSrcweir sal_Bool SAL_CALL OCallableStatement::wasNull(  ) throw(SQLException, RuntimeException)
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	return m_aValue.isNull();
65cdf0e10cSrcweir }
66cdf0e10cSrcweir // -------------------------------------------------------------------------
67cdf0e10cSrcweir 
getBoolean(sal_Int32 columnIndex)68cdf0e10cSrcweir sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	GET_PARAM()
71cdf0e10cSrcweir 	return m_aValue;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir // -------------------------------------------------------------------------
getByte(sal_Int32 columnIndex)74cdf0e10cSrcweir sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	GET_PARAM()
77cdf0e10cSrcweir 	return m_aValue;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir // -------------------------------------------------------------------------
getBytes(sal_Int32 columnIndex)80cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	GET_PARAM()
83cdf0e10cSrcweir 	return m_aValue;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir // -------------------------------------------------------------------------
getDate(sal_Int32 columnIndex)86cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	GET_PARAM()
89cdf0e10cSrcweir 	return m_aValue;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir // -------------------------------------------------------------------------
getDouble(sal_Int32 columnIndex)92cdf0e10cSrcweir double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	GET_PARAM()
95cdf0e10cSrcweir 	return m_aValue;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir // -------------------------------------------------------------------------
98cdf0e10cSrcweir 
getFloat(sal_Int32 columnIndex)99cdf0e10cSrcweir float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	GET_PARAM()
102cdf0e10cSrcweir 	return m_aValue;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir // -------------------------------------------------------------------------
105cdf0e10cSrcweir 
getInt(sal_Int32 columnIndex)106cdf0e10cSrcweir sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	GET_PARAM()
109cdf0e10cSrcweir 	return m_aValue;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -------------------------------------------------------------------------
112cdf0e10cSrcweir 
getLong(sal_Int32 columnIndex)113cdf0e10cSrcweir sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	GET_PARAM()
116cdf0e10cSrcweir 	return (sal_Int64)m_aValue.getCurrency().int64;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir // -------------------------------------------------------------------------
119cdf0e10cSrcweir 
getObject(sal_Int32,const Reference<::com::sun::star::container::XNameAccess> &)120cdf0e10cSrcweir Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
123cdf0e10cSrcweir 	return Any();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir // -------------------------------------------------------------------------
126cdf0e10cSrcweir 
getShort(sal_Int32 columnIndex)127cdf0e10cSrcweir sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	GET_PARAM()
130cdf0e10cSrcweir 	return m_aValue;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir // -------------------------------------------------------------------------
133cdf0e10cSrcweir 
getString(sal_Int32 columnIndex)134cdf0e10cSrcweir ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	GET_PARAM()
137cdf0e10cSrcweir 	return m_aValue;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -------------------------------------------------------------------------
140cdf0e10cSrcweir 
getTime(sal_Int32 columnIndex)141cdf0e10cSrcweir  ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	GET_PARAM()
144cdf0e10cSrcweir 	return m_aValue;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir // -------------------------------------------------------------------------
147cdf0e10cSrcweir 
getTimestamp(sal_Int32 columnIndex)148cdf0e10cSrcweir  ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir 	GET_PARAM()
151cdf0e10cSrcweir 	return m_aValue;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir // -------------------------------------------------------------------------
154cdf0e10cSrcweir 
registerOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,const::rtl::OUString &)155cdf0e10cSrcweir void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	ADOParameter* pParam = NULL;
158cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
159cdf0e10cSrcweir 	if(pParam)
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
162cdf0e10cSrcweir 		pParam->put_Direction(adParamOutput);
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir }
165cdf0e10cSrcweir // -------------------------------------------------------------------------
registerNumericOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,sal_Int32 scale)166cdf0e10cSrcweir void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir 	ADOParameter* pParam = NULL;
169cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
170cdf0e10cSrcweir 	if(pParam)
171cdf0e10cSrcweir 	{
172cdf0e10cSrcweir 		pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
173cdf0e10cSrcweir 		pParam->put_Direction(adParamOutput);
174cdf0e10cSrcweir 		pParam->put_NumericScale((sal_Int8)scale);
175cdf0e10cSrcweir 	}
176cdf0e10cSrcweir }
177cdf0e10cSrcweir // -------------------------------------------------------------------------
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
getBinaryStream(sal_Int32)180cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
183cdf0e10cSrcweir 	return NULL;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir // -------------------------------------------------------------------------
getCharacterStream(sal_Int32)186cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
189cdf0e10cSrcweir 	return NULL;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir // -------------------------------------------------------------------------
192cdf0e10cSrcweir 
getArray(sal_Int32)193cdf0e10cSrcweir Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
194cdf0e10cSrcweir {
195cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
196cdf0e10cSrcweir 	return NULL;
197cdf0e10cSrcweir }
198cdf0e10cSrcweir // -------------------------------------------------------------------------
199cdf0e10cSrcweir 
getClob(sal_Int32)200cdf0e10cSrcweir Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
203cdf0e10cSrcweir 	return NULL;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir // -------------------------------------------------------------------------
getBlob(sal_Int32)206cdf0e10cSrcweir Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
209cdf0e10cSrcweir 	return NULL;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir // -------------------------------------------------------------------------
212cdf0e10cSrcweir 
getRef(sal_Int32)213cdf0e10cSrcweir Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
216cdf0e10cSrcweir 	return NULL;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir // -------------------------------------------------------------------------
219cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()220cdf0e10cSrcweir void SAL_CALL OCallableStatement::acquire() throw()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir 	OPreparedStatement::acquire();
223cdf0e10cSrcweir }
224cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()225cdf0e10cSrcweir void SAL_CALL OCallableStatement::release() throw()
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	OPreparedStatement::release();
228cdf0e10cSrcweir }
229cdf0e10cSrcweir // -----------------------------------------------------------------------------
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 
232