1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ACallableStatement.cxx,v $
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");
47 ADOParameter* pParam = NULL; \
48 m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&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
)
80 // -------------------------------------------------------------------------
81 sal_Int8 SAL_CALL
OCallableStatement::getByte( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
86 // -------------------------------------------------------------------------
87 Sequence
< sal_Int8
> SAL_CALL
OCallableStatement::getBytes( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
92 // -------------------------------------------------------------------------
93 ::com::sun::star::util::Date SAL_CALL
OCallableStatement::getDate( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
98 // -------------------------------------------------------------------------
99 double SAL_CALL
OCallableStatement::getDouble( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
104 // -------------------------------------------------------------------------
106 float SAL_CALL
OCallableStatement::getFloat( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
111 // -------------------------------------------------------------------------
113 sal_Int32 SAL_CALL
OCallableStatement::getInt( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
118 // -------------------------------------------------------------------------
120 sal_Int64 SAL_CALL
OCallableStatement::getLong( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
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 );
132 // -------------------------------------------------------------------------
134 sal_Int16 SAL_CALL
OCallableStatement::getShort( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
139 // -------------------------------------------------------------------------
141 ::rtl::OUString SAL_CALL
OCallableStatement::getString( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
146 // -------------------------------------------------------------------------
148 ::com::sun::star::util::Time SAL_CALL
OCallableStatement::getTime( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
153 // -------------------------------------------------------------------------
155 ::com::sun::star::util::DateTime SAL_CALL
OCallableStatement::getTimestamp( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
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
);
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
);
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 );
192 // -------------------------------------------------------------------------
193 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
OCallableStatement::getCharacterStream( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
195 ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
198 // -------------------------------------------------------------------------
200 Reference
< XArray
> SAL_CALL
OCallableStatement::getArray( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
202 ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
205 // -------------------------------------------------------------------------
207 Reference
< XClob
> SAL_CALL
OCallableStatement::getClob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
209 ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
212 // -------------------------------------------------------------------------
213 Reference
< XBlob
> SAL_CALL
OCallableStatement::getBlob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
215 ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
218 // -------------------------------------------------------------------------
220 Reference
< XRef
> SAL_CALL
OCallableStatement::getRef( sal_Int32
/*columnIndex*/) throw(SQLException
, RuntimeException
)
222 ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
225 // -------------------------------------------------------------------------
226 // -----------------------------------------------------------------------------
227 void SAL_CALL
OCallableStatement::acquire() throw()
229 OPreparedStatement::acquire();
231 // -----------------------------------------------------------------------------
232 void SAL_CALL
OCallableStatement::release() throw()
234 OPreparedStatement::release();
236 // -----------------------------------------------------------------------------