update dev300-m58
[ooovba.git] / connectivity / source / drivers / ado / ACallableStatement.cxx
blob6f15fdba76abcb0b1913f2dd5b7ceb5bb428f143
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: ACallableStatement.cxx,v $
10 * $Revision: 1.10 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "ado/ACallableStatement.hxx"
34 #include <connectivity/dbexception.hxx>
36 using namespace connectivity::ado;
37 using namespace com::sun::star::uno;
38 using namespace com::sun::star::lang;
39 using namespace com::sun::star::beans;
40 using namespace com::sun::star::sdbc;
41 using namespace com::sun::star::container;
42 using namespace com::sun::star::lang;
44 IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
46 #define GET_PARAM() \
47 ADOParameter* pParam = NULL; \
48 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam); \
49 if(pParam) \
50 pParam->get_Value(&m_aValue);
51 //**************************************************************
52 //************ Class: java.sql.CallableStatement
53 //**************************************************************
54 OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql )
55 : OPreparedStatement( _pConnection, _TypeInfo, sql )
57 m_Command.put_CommandType(adCmdStoredProc);
59 // -------------------------------------------------------------------------
61 Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
63 Any aRet = OPreparedStatement::queryInterface(rType);
64 return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
66 // -------------------------------------------------------------------------
69 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
71 return m_aValue.isNull();
73 // -------------------------------------------------------------------------
75 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
77 GET_PARAM()
78 return m_aValue;
80 // -------------------------------------------------------------------------
81 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
83 GET_PARAM()
84 return m_aValue;
86 // -------------------------------------------------------------------------
87 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
89 GET_PARAM()
90 return m_aValue;
92 // -------------------------------------------------------------------------
93 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
95 GET_PARAM()
96 return m_aValue;
98 // -------------------------------------------------------------------------
99 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
101 GET_PARAM()
102 return m_aValue;
104 // -------------------------------------------------------------------------
106 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
108 GET_PARAM()
109 return m_aValue;
111 // -------------------------------------------------------------------------
113 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
115 GET_PARAM()
116 return m_aValue;
118 // -------------------------------------------------------------------------
120 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
122 GET_PARAM()
123 return (sal_Int64)m_aValue.getCurrency().int64;
125 // -------------------------------------------------------------------------
127 Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
129 ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
130 return Any();
132 // -------------------------------------------------------------------------
134 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
136 GET_PARAM()
137 return m_aValue;
139 // -------------------------------------------------------------------------
141 ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
143 GET_PARAM()
144 return m_aValue;
146 // -------------------------------------------------------------------------
148 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
150 GET_PARAM()
151 return m_aValue;
153 // -------------------------------------------------------------------------
155 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
157 GET_PARAM()
158 return m_aValue;
160 // -------------------------------------------------------------------------
162 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
164 ADOParameter* pParam = NULL;
165 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
166 if(pParam)
168 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
169 pParam->put_Direction(adParamOutput);
172 // -------------------------------------------------------------------------
173 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
175 ADOParameter* pParam = NULL;
176 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
177 if(pParam)
179 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
180 pParam->put_Direction(adParamOutput);
181 pParam->put_NumericScale((sal_Int8)scale);
184 // -------------------------------------------------------------------------
187 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
189 ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
190 return NULL;
192 // -------------------------------------------------------------------------
193 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
195 ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
196 return NULL;
198 // -------------------------------------------------------------------------
200 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
202 ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
203 return NULL;
205 // -------------------------------------------------------------------------
207 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
209 ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
210 return NULL;
212 // -------------------------------------------------------------------------
213 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
215 ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
216 return NULL;
218 // -------------------------------------------------------------------------
220 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
222 ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
223 return NULL;
225 // -------------------------------------------------------------------------
226 // -----------------------------------------------------------------------------
227 void SAL_CALL OCallableStatement::acquire() throw()
229 OPreparedStatement::acquire();
231 // -----------------------------------------------------------------------------
232 void SAL_CALL OCallableStatement::release() throw()
234 OPreparedStatement::release();
236 // -----------------------------------------------------------------------------