1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include "ado/ACallableStatement.hxx"
31*cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir using namespace connectivity::ado;
34*cdf0e10cSrcweir using namespace com::sun::star::uno;
35*cdf0e10cSrcweir using namespace com::sun::star::lang;
36*cdf0e10cSrcweir using namespace com::sun::star::beans;
37*cdf0e10cSrcweir using namespace com::sun::star::sdbc;
38*cdf0e10cSrcweir using namespace com::sun::star::container;
39*cdf0e10cSrcweir using namespace com::sun::star::lang;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #define GET_PARAM()													\
44*cdf0e10cSrcweir 	ADOParameter* pParam = NULL;									\
45*cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam);		\
46*cdf0e10cSrcweir 	if(pParam)														\
47*cdf0e10cSrcweir 		pParam->get_Value(&m_aValue);
48*cdf0e10cSrcweir //**************************************************************
49*cdf0e10cSrcweir //************ Class: java.sql.CallableStatement
50*cdf0e10cSrcweir //**************************************************************
51*cdf0e10cSrcweir OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql )
52*cdf0e10cSrcweir 				: OPreparedStatement( _pConnection, _TypeInfo, sql )
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir 	m_Command.put_CommandType(adCmdStoredProc);
55*cdf0e10cSrcweir }
56*cdf0e10cSrcweir // -------------------------------------------------------------------------
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 	Any aRet = OPreparedStatement::queryInterface(rType);
61*cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir // -------------------------------------------------------------------------
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir sal_Bool SAL_CALL OCallableStatement::wasNull(  ) throw(SQLException, RuntimeException)
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	return m_aValue.isNull();
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir // -------------------------------------------------------------------------
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 	GET_PARAM()
75*cdf0e10cSrcweir 	return m_aValue;
76*cdf0e10cSrcweir }
77*cdf0e10cSrcweir // -------------------------------------------------------------------------
78*cdf0e10cSrcweir sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir 	GET_PARAM()
81*cdf0e10cSrcweir 	return m_aValue;
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir // -------------------------------------------------------------------------
84*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir 	GET_PARAM()
87*cdf0e10cSrcweir 	return m_aValue;
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir // -------------------------------------------------------------------------
90*cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir 	GET_PARAM()
93*cdf0e10cSrcweir 	return m_aValue;
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir // -------------------------------------------------------------------------
96*cdf0e10cSrcweir double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	GET_PARAM()
99*cdf0e10cSrcweir 	return m_aValue;
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir // -------------------------------------------------------------------------
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	GET_PARAM()
106*cdf0e10cSrcweir 	return m_aValue;
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir // -------------------------------------------------------------------------
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	GET_PARAM()
113*cdf0e10cSrcweir 	return m_aValue;
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir // -------------------------------------------------------------------------
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	GET_PARAM()
120*cdf0e10cSrcweir 	return (sal_Int64)m_aValue.getCurrency().int64;
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir // -------------------------------------------------------------------------
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
127*cdf0e10cSrcweir 	return Any();
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir // -------------------------------------------------------------------------
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir 	GET_PARAM()
134*cdf0e10cSrcweir 	return m_aValue;
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir // -------------------------------------------------------------------------
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	GET_PARAM()
141*cdf0e10cSrcweir 	return m_aValue;
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir // -------------------------------------------------------------------------
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir  ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	GET_PARAM()
148*cdf0e10cSrcweir 	return m_aValue;
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir // -------------------------------------------------------------------------
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir  ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	GET_PARAM()
155*cdf0e10cSrcweir 	return m_aValue;
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir // -------------------------------------------------------------------------
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	ADOParameter* pParam = NULL;
162*cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
163*cdf0e10cSrcweir 	if(pParam)
164*cdf0e10cSrcweir 	{
165*cdf0e10cSrcweir 		pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
166*cdf0e10cSrcweir 		pParam->put_Direction(adParamOutput);
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir // -------------------------------------------------------------------------
170*cdf0e10cSrcweir void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir 	ADOParameter* pParam = NULL;
173*cdf0e10cSrcweir 	m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
174*cdf0e10cSrcweir 	if(pParam)
175*cdf0e10cSrcweir 	{
176*cdf0e10cSrcweir 		pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
177*cdf0e10cSrcweir 		pParam->put_Direction(adParamOutput);
178*cdf0e10cSrcweir 		pParam->put_NumericScale((sal_Int8)scale);
179*cdf0e10cSrcweir 	}
180*cdf0e10cSrcweir }
181*cdf0e10cSrcweir // -------------------------------------------------------------------------
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
187*cdf0e10cSrcweir 	return NULL;
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir // -------------------------------------------------------------------------
190*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
193*cdf0e10cSrcweir 	return NULL;
194*cdf0e10cSrcweir }
195*cdf0e10cSrcweir // -------------------------------------------------------------------------
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
198*cdf0e10cSrcweir {
199*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
200*cdf0e10cSrcweir 	return NULL;
201*cdf0e10cSrcweir }
202*cdf0e10cSrcweir // -------------------------------------------------------------------------
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
207*cdf0e10cSrcweir 	return NULL;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir // -------------------------------------------------------------------------
210*cdf0e10cSrcweir Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
213*cdf0e10cSrcweir 	return NULL;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir // -------------------------------------------------------------------------
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
220*cdf0e10cSrcweir 	return NULL;
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir // -------------------------------------------------------------------------
223*cdf0e10cSrcweir // -----------------------------------------------------------------------------
224*cdf0e10cSrcweir void SAL_CALL OCallableStatement::acquire() throw()
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir 	OPreparedStatement::acquire();
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir // -----------------------------------------------------------------------------
229*cdf0e10cSrcweir void SAL_CALL OCallableStatement::release() throw()
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir 	OPreparedStatement::release();
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir // -----------------------------------------------------------------------------
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 
236