Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / ado / ACallableStatement.cxx
blob0d8846f802f21957e6a4b9a02d7e64dce704c818
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 #include "ado/ACallableStatement.hxx"
21 #include <connectivity/dbexception.hxx>
23 using namespace connectivity::ado;
24 using namespace com::sun::star::uno;
25 using namespace com::sun::star::lang;
26 using namespace com::sun::star::beans;
27 using namespace com::sun::star::sdbc;
28 using namespace com::sun::star::container;
30 IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
32 #define GET_PARAM() \
33 ADOParameter* pParam = NULL; \
34 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam); \
35 if(pParam) \
36 pParam->get_Value(&m_aValue);
38 //************ Class: java.sql.CallableStatement
40 OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const OUString& sql )
41 : OPreparedStatement( _pConnection, _TypeInfo, sql )
43 m_Command.put_CommandType(adCmdStoredProc);
47 Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
49 Any aRet = OPreparedStatement::queryInterface(rType);
50 return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
55 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
57 return m_aValue.isNull();
61 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
63 GET_PARAM()
64 return m_aValue;
67 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
69 GET_PARAM()
70 return m_aValue;
73 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
75 GET_PARAM()
76 return m_aValue;
79 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
81 GET_PARAM()
82 return m_aValue;
85 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
87 GET_PARAM()
88 return m_aValue;
92 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
94 GET_PARAM()
95 return m_aValue;
99 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
101 GET_PARAM()
102 return m_aValue;
106 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
108 GET_PARAM()
109 return (sal_Int64)m_aValue.getCurrency().int64;
113 Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
115 ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
116 return Any();
120 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
122 GET_PARAM()
123 return m_aValue;
127 OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
129 GET_PARAM()
130 return m_aValue;
134 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
136 GET_PARAM()
137 return m_aValue;
141 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
143 GET_PARAM()
144 return m_aValue;
148 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
150 ADOParameter* pParam = NULL;
151 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
152 if(pParam)
154 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
155 pParam->put_Direction(adParamOutput);
159 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
161 ADOParameter* pParam = NULL;
162 m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
163 if(pParam)
165 pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
166 pParam->put_Direction(adParamOutput);
167 pParam->put_NumericScale((sal_Int8)scale);
173 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
175 ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
176 return NULL;
179 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
181 ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
182 return NULL;
186 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
188 ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
189 return NULL;
193 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
195 ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
196 return NULL;
199 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
201 ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
202 return NULL;
206 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
208 ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
209 return NULL;
213 void SAL_CALL OCallableStatement::acquire() throw()
215 OPreparedStatement::acquire();
218 void SAL_CALL OCallableStatement::release() throw()
220 OPreparedStatement::release();
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */